Skip to Content.
Sympa Menu

freetds - [freetds] dblib patch

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Thompson, Bill D (London)" <bill_d_thompson AT ml.com>
  • To: <freetds AT lists.ibiblio.org>
  • Subject: [freetds] dblib patch
  • Date: Fri, 1 Jul 2005 14:18:56 +0100

Hi guys,

I haven't been around much lately - too much (unrelated) work to do
elsewhere.

Here's a little patch to dblib for a couple of issues. I've applied it
to my version of 0.63.

The first change is for (free)bcp.

This fixes a problem where we attempt to bcp in from file to a NOT NULL
(var)char column.
If the host file contains just blanks, we "rtrim" the data down to a
zero length string.
bcp then interprets this as a NULL and we get an error

"attempt to copy NULL to a NOT NULL column"

or somesuch.

The second change is for dbresults.

If our sql command is to "exec stored_procedure", and the stored
procedure has no result set(s), we are failing to generate a SUCCEED
return from dbresults, just returning NO_MORE_RESULTS.

here's the patch from my version of 0.63:

diff -u -r freetds-0.63/src/dblib/bcp.c
freetds-0.63.mine/src/dblib/bcp.c
--- freetds-0.63/src/dblib/bcp.c 2005-02-07 10:28:25.000000000 +0000
+++ freetds-0.63.mine/src/dblib/bcp.c 2005-06-29 15:49:12.784615000
+0100
@@ -2826,6 +2826,10 @@
return bufpos;
}

+/**
+ * Trim trailing blanks from an input string,
+ * Always leaving ONE blank in an entirely blank string.
+ */
static int
rtrim(char *istr, int ilen)
{
@@ -2836,6 +2840,14 @@
*t = '\0';
olen--;
}
+
+ /* put back a single blank, if we've got rid of them all */
+
+ if (ilen && !olen) {
+ *t = ' ';
+ olen = 1;
+ }
+
return olen;
}

diff -u -r freetds-0.63/src/dblib/dblib.c
freetds-0.63.mine/src/dblib/dblib.c
--- freetds-0.63/src/dblib/dblib.c 2005-01-07 16:34:39.000000000 +0000
+++ freetds-0.63.mine/src/dblib/dblib.c 2005-04-20 12:57:44.643915000
+0100
@@ -1345,6 +1345,7 @@
break;

case TDS_DONE_RESULT:
+ case TDS_DONEPROC_RESULT:

/* A done token signifies the end of a logical command.
* There are three possibilities:
@@ -1375,7 +1376,6 @@
}


- case TDS_DONEPROC_RESULT:
case TDS_DONEINPROC_RESULT:

/* We should only return SUCCEED on a command within a
*/
--------------------------------------------------------

If you are not an intended recipient of this e-mail, please notify the
sender, delete it and do not read, act upon, print, disclose, copy, retain or
redistribute it. Click here for important additional terms relating to this
e-mail. http://www.ml.com/email_terms/
--------------------------------------------------------




Archive powered by MHonArc 2.6.24.

Top of Page