SCM

[#1011287] Column Ordinal offset bug in the NpgsqlDataReader GetSchemaTable method

View Trackers | Bugs | Download .csv | Monitor

Date:
2012-12-05 06:05
Priority:
3
State:
Open
Submitted by:
Richard Meyer (meyerrj)
Assigned to:
Nobody (None)
Npgsql Version:
2.0.12beta
Category:
None
Group:
None
Resolution:
None
Summary:
Column Ordinal offset bug in the NpgsqlDataReader GetSchemaTable method

Detailed description
In working on a custom data access layer with a colleague, we discovered an issue where the column ordinal values are incremented by 1 when going from the DataReader to the DataTable objects.

Lines 515 and 607 of Ngpgsql.NpgsqlDataReader are the culprits in version 2.0.12.

Per the MSDN specifications, ColumnOrdinal is a zero-based index:

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.getschematable.aspx

Attached is a patched version of NgpgsqlDataReader.cs that removes the + 1.

Followup

Message
Date: 2013-07-22 23:33
Sender: Francisco Figueiredo jr.

Hi, Richard!

I'm working on this bug report and while the documentation from .net 4.0 and above talks about the 0-based column ordinal, the documentation from .net 3.5 and below says the following:

"The ordinal of the column. This is zero for the bookmark column of the row, if any. Other columns are numbered starting with one. This column cannot contain a null value."

When we started to work on this code, there was only .net 2.0 and that's why we started with a column ordinal of 1. It is strange that on .net 4.0 and above they changed it to be 0-based.

I'll check how to implement that so it is consistent with sqlclient provider and .net versions.

Attached Files:

Attachments:
NpgsqlDataReader.cs

Changes:

Field Old Value Date By
File Added784: NpgsqlDataReader.cs2012-12-05 06:05meyerrj
Powered By FusionForge