OpenDBX

for Project:

Open Database abstraction layer

Register as a new user

Task #36 — fieldValue function only returns null after first null result

Attached to Project — OpenDBX
Opened by Dominic Jones (djones) - Wednesday, 26 Jan 2011, 9:40pm
Bug Report Medium
Library Normal
Unconfirmed 1.4.x
No-one Undecided
Windows 0% complete
If a field from a table being read via OpenDBX has the value null, it appears that any further reads from the column involved will also return null, even if the correct value for that row is different.

This problem occurred in the following code from a utility for moving data row-by-row from a query on one database to a table in another.

while ((transfer_status = data.getResult()) != ODBX_RES_DONE)
{
while (data.getRow() != ODBX_ROW_DONE)
{
std::string insert_str("INSERT INTO ");
insert_str.append(argv[optind+11]);
insert_str.append(" VALUES (");
for (int counter=0;counter < data.columnCount();++counter)
{
if (counter > 0) insert_str.append(",");
const char * value = data.fieldValue(counter);
if (value != NULL)
{
insert_str.append("'");
string valueStr(value);
string escapedValue;
target.escape(value,escapedValue);
insert_str.append(escapedValue);
insert_str.append("'");
}
else
{
insert_str.append("NULL");
}
}
insert_str.append(");");
Stmt s5 = target.create(insert_str);

(...)

Comments (6) | Attachments (0) | Related Tasks (0/0) | Notifications (1) | Reminders (0) | History |

Comment by Norbert Sendetzky - Saturday, 29 Jan 2011, 3:55pm

Which database backend are you using?
Do you get the same behavior using a Linux system?

Comment by Dominic Jones - Monday, 31 Jan 2011, 6:54pm

The code was using two backends, transferring data from SQL Server to PostgreSQL. The SQL Server interaction appears to cause the problem.

I don't have an appropriate Linux system available on which to test the behavior.

To clarify, I'm using mingw on Windows.

Comment by Norbert Sendetzky - Tuesday, 1 Feb 2011, 11:35pm

Which backend are you using for connecting to your MSSQL server? ODBC or mssql? The later one depends on FreeTDS and is mainly for Unix-like systems.

Comment by Dominic Jones - Wednesday, 2 Feb 2011, 10:26pm

I'm using mssql as the backend, with FreeTDS.

Comment by Norbert Sendetzky - Monday, 7 Feb 2011, 10:28am

This might be a bug in FreeTDS. Which version are you using?

Are you willing to debug into this issue? If yes, we should move to the mailing list as it allows us faster discussions about this topic.

Thank you

Comment by Dominic Jones - Tuesday, 8 Feb 2011, 4:38pm

Yes, it could be a FreeTDS bug. I'm using version 0.82, which appears to be current.

I can get involved in debugging the issue. However, I'm not on the mailing list (yet).