Re: How does FreeTDS support bulk export

Johnny Yan <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <DM5PR03MB273203DE2A0CDD4653893A38C3130@DM5PR03MB2732.namprd03.prod.outlook.com>
Hi Bill, 

So sorry about the delay. 

The "bulk export" is referred to insert multiple rows into a temp table which we just created. In terms of the ODBC API calls, the stack is roughly like this, 

SQLAllocHandle( SQL_HANDLE_STMT, ...) );
SQLExecDirectW(..., "CREATE TABLE [#temp_table_name] (columns)",...);

SQLAllocHandle( SQL_HANDLE_STMT, ... );
SQLPrepare(..., "INSERT INTO [#temp_table_name] (columns) VALUES (?,...) ",...)
SQLSetStmtAttrW(..., SQL_ATTR_PARAMSET_SIZE, num_rows_export, SQL_IS_UINTEGER );
SQLBindParameter(..., SQL_PARAM_INPUT, ...)
SQLExecDirect(...,"INSERT INTO [#temp_table_name] (columns) VALUES (?,...) ",...)

With MS Native Client on Windows and/or Simba driver on OSX, this is working just fine. But with FreeTDS, we found that the placeholds(?) in the prepared statement were replaced with the value of the params. I actually debugged a little bit of the FreeTDS code. In _SQLExecute(TDS_STMT * stmt):odbc.c(3270), it goes into the branch "else if (stmt->query)" and the following comments are confusing since we're passing in a prepared statement. Because of this, the code path then goes into tds_multiple_query -> tds_send_emulated_execute, which looks like really "emulating"(bulk export).

I suspect the "stmt->query" condition might be misleading in the first place but not sure at all. What do you think?

If you need more info, please let me know.

Thanks,
Johnny

-----Original Message-----
From: FreeTDS [mailto:[email protected]] On Behalf Of Thompson, William
Sent: Wednesday, August 10, 2016 5:37 AM
To: FreeTDS Development Group <[email protected]>
Subject: Re: [freetds] How does FreeTDS support bulk export

Hi Johnny,

What is this "bulk export" you refer to?
If there's INSERT statements going on, it sounds more like an import to me...
What is wrapped around FreeTDS in your application? 
I think it's more likely that it's this that is deciding on the approach of generating multiple INSERT statements, rather than FreeTDS.

Bill

-----Original Message-----
From: FreeTDS [mailto:[email protected]] On Behalf Of Johnny Yan
Sent: 09 August 2016 23:29
To: [email protected]
Subject: [freetds] How does FreeTDS support bulk export

Hi,

We've observed, through the freetds.log, that when we try to bulk export multiple rows, what FreeTDS really does is replacing the ? placehold with the corresponding param value(s), then concatenating multiple "INSERT INTO..." statements into a single query, and finally sent it through the wire. Is this what we're supposed to expect? How does FreeTDS support bulk export?

Thanks,
Johnny
_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds

----------------------------------------------------------------------
This message, and any attachments, is for the intended recipient(s) only, may contain information that is privileged, confidential and/or proprietary and subject to important terms and conditions available at http://www.bankofamerica.com/emaildisclaimer.   If you are not the intended recipient, please delete this message.
_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.