[freetds] dblib patch

Patrick Dunnigan patrick.dunnigan at centivia.com
Fri Jul 1 09:47:40 EDT 2005


The bcp patch: is this related to file based bulk copies only or any kind 
(from memory)?
Thanks
----- Original Message ----- 
From: "Thompson, Bill D (London)" <bill_d_thompson at ml.com>
To: <freetds at lists.ibiblio.org>
Sent: Friday, July 01, 2005 9:18 AM
Subject: [freetds] dblib patch


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/
--------------------------------------------------------
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds





More information about the FreeTDS mailing list