Skip to Content.
Sympa Menu

freetds - [freetds] fix and small enhancement to freebcp

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <bill.d.thompson AT baml.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: [freetds] fix and small enhancement to freebcp
  • Date: Tue, 05 Apr 2011 13:55:35 +0100

Hi Guys,

A couple of things were reported to me about bcp/freebcp.

1) The bulk copy hint "FIRE_TRIGGERS" is not supported.
2) freebcp errors out if the -h "HINT" option is used, viz:

Msg 20076, Level 7
bcp_init must be called before any other bcp routines
db-lib: Unable to set hint "TABLOCK"

Please find attached my version of the fixes submitted by the reporter

Regards,

Bill Thompson

<<bcpdiffs.txt>>

----------------------------------------------------------------------
This message w/attachments (message) is intended solely for the use of the
intended recipient(s) and may contain information that is privileged,
confidential or proprietary. If you are not an intended recipient, please
notify the sender, and then please delete and destroy all copies and
attachments, and be advised that any review or dissemination of, or the
taking of any action in reliance on, the information contained in or attached
to this message is prohibited.
Unless specifically indicated, this message is not an offer to sell or a
solicitation of any investment products or other financial product or
service, an official confirmation of any transaction, or an official
statement of Sender. Subject to applicable law, Sender may intercept,
monitor, review and retain e-communications (EC) traveling through its
networks/systems and may produce any such EC to regulators, law enforcement,
in litigation and as required by law.
The laws of the country of each sender/recipient may impact the handling of
EC, and EC may be archived, supervised and produced in countries other than
the country in which you are located. This message cannot be guaranteed to be
secure or free of errors or viruses.

References to "Sender" are references to any subsidiary of Bank of America
Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are
Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a
Condition to Any Banking Service or Activity * Are Not Insured by Any Federal
Government Agency. Attachments that are part of this EC may have additional
important disclosures and disclaimers, which you should read. This message is
subject to terms available at the following link:
http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you
consent to the foregoing.
--- /home/thompbil/freetds-0.83.dev.20110314/src/dblib/bcp.c Fri Jan 14
14:18:15 2011
+++ ./bcp.c Tue Apr 5 13:05:06 2011
@@ -614,6 +614,7 @@
* - \b KILOBYTES_PER_BATCH The approximate number of kilobytes
to use for a batch size
* - \b TABLOCK Lock the table
* - \b CHECK_CONSTRAINTS Apply constraints
+ * - \b FIRE_TRIGGERS Fire any INSERT triggers on the target
table
* \param valuelen The strlen of \a value.
*
* \return SUCCEED or FAIL.
@@ -626,7 +627,7 @@
{
int i;
static const char *const hints[] = {
- "ORDER", "ROWS_PER_BATCH", "KILOBYTES_PER_BATCH", "TABLOCK",
"CHECK_CONSTRAINTS", NULL
+ "ORDER", "ROWS_PER_BATCH", "KILOBYTES_PER_BATCH", "TABLOCK",
"CHECK_CONSTRAINTS", "FIRE_TRIGGERS", NULL
};

tdsdump_log(TDS_DBG_FUNC, "bcp_options(%p, %d, %p, %d)\n", dbproc,
option, value, valuelen);
--- /home/thompbil/freetds-0.83.dev.20110314/src/apps/freebcp.c Sun Mar 13
21:32:49 2011
+++ ./freebcp.c Tue Apr 5 13:30:37 2011
@@ -444,15 +444,6 @@
dbloginfree(login);
login = NULL;

- /* set hint if any */
- if (pdata->hint) {
- int erc = bcp_options(*pdbproc, BCPHINTS, (BYTE *)
pdata->hint, strlen(pdata->hint));
-
- if (erc != SUCCEED)
- fprintf(stderr, "db-lib: Unable to set hint
\"%s\"\n", pdata->hint);
- return FALSE;
- }
-
return (TRUE);

}
@@ -496,6 +487,9 @@
if (FAIL == bcp_init(dbproc, pdata->dbobject, pdata->hostfilename,
pdata->errorfile, dir))
return FALSE;

+ if (!set_bcp_hints(pdata, dbproc))
+ return FALSE;
+
if (pdata->Eflag) {

bcp_control(dbproc, BCPKEEPIDENTITY, 1);
@@ -591,6 +585,9 @@
if (FAIL == bcp_init(dbproc, pdata->dbobject, pdata->hostfilename,
pdata->errorfile, dir))
return FALSE;

+ if (!set_bcp_hints(pdata, dbproc))
+ return FALSE;
+
if (pdata->Eflag) {

bcp_control(dbproc, BCPKEEPIDENTITY, 1);
@@ -649,6 +646,9 @@
if (FAIL == bcp_init(dbproc, pdata->dbobject, pdata->hostfilename,
pdata->errorfile, dir))
return FALSE;

+ if (!set_bcp_hints(pdata, dbproc))
+ return FALSE;
+
if (pdata->Eflag) {

bcp_control(dbproc, BCPKEEPIDENTITY, 1);
@@ -744,6 +744,20 @@

return TRUE;
}
+
+int
+set_bcp_hints(BCPPARAMDATA *pdata, DBPROCESS *pdbproc)
+{
+ int erc;
+ /* set hint if any */
+ if (pdata->hint) {
+ if (erc = bcp_options(pdbproc, BCPHINTS, (BYTE *)
pdata->hint, strlen(pdata->hint)) != SUCCEED) {
+ fprintf(stderr, "db-lib: Unable to set hint
\"%s\"\n", pdata->hint);
+ return FALSE;
+ }
+ }
+ return TRUE;
+}

void
pusage(void)



Archive powered by MHonArc 2.6.24.

Top of Page