[Mono-dev] OdbcDataReader enhancement

Nagappan A nagappan at gmail.com
Tue Jul 8 21:28:53 EDT 2008


Hello Ernesto,

I appreciate your work :) The value of _dataTableSchema is not being used
anywhere, though its been filled each time. Good catch !

Could you please try running the unit test too and make sure it doesn't
break existing test cases.

Thanks
Nagappan

2008/7/8 Ernesto <equistango at gmail.com>:

>
> Hi, I was taking a look at OdbcDataReader.cs and found something that got
> my attention: a call to GetSchemaTable() in the class' constructor.
>
> The DataReader is supposed to be a very fast reader for forward-only
> queries, and getting complete schema information on every DataReader is a
> very expensive (and unsolicited) operation. The call seems completely
> unnecesary to me. Only  column information is necessary.
>
> This patch replaces two calls to GetSchemaTable() for calls to a new
> function GetColumns().
> It works perfectly in my tests and it's way much faster. Can someone please
> review and comment?
>
> Regards,
> Ernesto
>
>
> Index: OdbcDataReader.cs
> ===================================================================
> --- OdbcDataReader.cs   (revision 107477)
> +++ OdbcDataReader.cs   (working copy)
> @@ -75,7 +75,7 @@
>                        short colcount = 0;
>                        libodbc.SQLNumResultCols (hstmt, ref colcount);
>                        cols = new OdbcColumn [colcount];
> -                       GetSchemaTable ();
> +                       GetColumns ();
>                }
>
>                internal OdbcDataReader (OdbcCommand command,
> CommandBehavior behavior,
> @@ -225,6 +225,13 @@
>                        }
>                        return cols [ordinal];
>                }
> +
> +               // Load all column descriptions
> +               private void GetColumns ()
> +               {
> +                       for(int i = 0; i < cols.Length; i++)
> +                               GetColumn (i);
> +               }
>
>                public
>  #if NET_2_0
> @@ -913,7 +920,7 @@
>                                libodbc.SQLNumResultCols (hstmt, ref
> colcount);
>                                cols = new OdbcColumn [colcount];
>                                _dataTableSchema = null; // force fresh
> creation
> -                               GetSchemaTable ();
> +                               GetColumns ();
>                        }
>                        return (ret == OdbcReturn.Success);
>                }
>
>
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>


-- 
Linux Desktop (GUI Application) Testing Project -
http://ldtp.freedesktop.org
http://nagappanal.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080708/752a315b/attachment-0001.html 


More information about the Mono-devel-list mailing list