Skip to Content.
Sympa Menu

freetds - [freetds] dbilib - dbwritetext and big buffers

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: miscmail <miscmail AT fingerpost.co.uk>
  • To: freetds AT lists.ibiblio.org
  • Subject: [freetds] dbilib - dbwritetext and big buffers
  • Date: Wed, 14 Oct 2009 19:17:56 +0100

Hi all

I am trying to upgrade from freetds 0.62 to 0.82 and have a small problem with dbwritetext

In my program, if the data length < system_max then the program does a :

- dbwritetext with a data buffer set to NULL and the length set to the actual size.
- then a loop with dbmoretext to upload the chunks

But in 0.82 it just hangs ... with an error .....

In dblib/unittest/t0013.c there is some code which is similar to mine BUT it is wasted with a ''ifndef"

When I tried a file around 400k - it worked fine even though the 'set textsize' is 64512

So then I set the flag (and added missing variables numtowrite and numwritten) :
#define DBWRITE_OK_FOR_OVER_4K

.. recompiled and got the same hang as my code does

The actual code in t0013 is :

if (dbwritetext(dbproc, objname, textPtr, DBTXPLEN, timeStamp, FALSE, isiz, NULL) != SUCCEED)
return 15;
dbsqlok(dbproc);
dbresults(dbproc);

numtowrite = 0;
/* Send the update value in chunks. */
for (numwritten = 0; numwritten < isiz; numwritten += numtowrite) {
numtowrite = (isiz - numwritten);
if (numtowrite > BLOB_BLOCK_SIZE)
numtowrite = BLOB_BLOCK_SIZE;
dbmoretext(dbproc, (DBINT) numtowrite, blob + numwritten);
}
dbsqlok(dbproc);
while (dbresults(dbproc) != NO_MORE_RESULTS);

I checked the src/dblib/dblib.c an found there is a check-exit-if-null on the 'text' buffer parameter
- around line 6261 in dblib.c 0.82 there is a
CHECK_NULP(text, "dbwritetext", 8, FAIL);
which looks like it is doing the damage.

which means a call with a NULL text buffer never gets to do anything !

There is a snippet of code a few lines further down which catches NULLs (below) so I wonder if that CHECK is superfluous :

if (!text) {
dbproc->text_size = size;
dbproc->text_sent = 0;
return SUCCEED;
}

Is there something new in how dbwritetext works - or should I just comment out the offending CHECK_NULP line (BTW it aint in freetds 0.62)?

Waddatink

chris





Archive powered by MHonArc 2.6.24.

Top of Page