Skip to Content.
Sympa Menu

freetds - Re: [freetds] bulk copy error: Received invalid row length x frombcpclient. Minimum row size is y

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Patrick Dunnigan" <patrick.dunnigan AT centivia.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] bulk copy error: Received invalid row length x frombcpclient. Minimum row size is y
  • Date: Wed, 22 Jun 2005 10:57:43 -0400

Spot on Bill,

Thanks for the quick response (I should have sent this note out three hours
ago!).

Patrick
----- Original Message -----
From: "Thompson, Bill D (London)" <bill_d_thompson AT ml.com>
To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
Sent: Wednesday, June 22, 2005 10:42 AM
Subject: RE: [freetds] bulk copy error: Received invalid row length x
frombcpclient. Minimum row size is y


Hi Patrick,

You are probably using the wrong version of the TDS protocol to talk to
your server. My guess is you'll be using the default version 4.2.

the TDS version needs to be 5.0 for Sybase, 7.0 for SQL Server.

you usually set this in the freetds.conf file.


Bill

-----Original Message-----
From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of Patrick Dunnigan
Sent: 22 June 2005 15:34
To: freetds AT lists.ibiblio.org
Subject: [freetds] bulk copy error: Received invalid row length x from
bcpclient. Minimum row size is y


Hi,

I am attempting a bulk copy from a c program into SQL Server 2000 using
DBLib in freeTDS 0.63 RC11 (gcc 3.4.3, RH 9). I am getting an error
message that I cannot find any documentation on.

"Received invalid row length 2 from bcp client. Minimum row size is 4."

I know the row is longer 2 bytes (see below). Once this happened I
created a test table and C program. See below. Anyone with any ideas?

Thanks

Program output ---------------->
$ ./test_bcp
bcp'ing This is a test with a length of 14
sent
Msg 4807, Level 16, State 1
Server 'CENTIVIA_10', Line 1
Received invalid row length 2 from bcp client. Minimum row size is 4.
done
<----------------------

Table ddl --------------------->
CREATE TABLE [xxx] (
[col2] [varchar] (32) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
<------------------------------------

Compiled using gcc ------------------->
gcc -g -I/home/test_user/dev/freetds-0.63RC11/include -Wall
-Wno-strict-aliasing -g -O2 -c -o test_bcp.o test_bcp.c
gcc -o test_bcp test_bcp.o -L/home/test_user/lib -lsybdb
<----------------------------------


program source (included the msg and error handler code)
-------------------------->
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sqldb.h>
int
syb_msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int
severity, char *msgtext, char *srvname, char *procname, int line)
{
char var_value[31];
int i;
char *c;

if (msgno == 5701 || /* database context change */
msgno == 5703 || /* language changed */
msgno == 5704) { /* charset changed */

if (msgtext != NULL && (c = strchr(msgtext, '\'')) !=
NULL) {
i = 0;
for (++c; i <= 30 && *c != '\0' && *c != '\'';
++c)
var_value[i++] = *c;
var_value[i] = '\0';

}
return 0;
}

if (severity >= 0 || msgno == 0) {
if (msgno > 0 && severity > 0) {
fprintf(stdout, "Msg %d, Level %d, State %d\n",
(int) msgno, (int) severity, (int) msgstate);
fprintf(stdout, "Server '%s'", srvname);
if (procname != NULL && *procname != '\0')
fprintf(stdout, ", Procedure '%s'",
procname);
if (line > 0)
fprintf(stdout, ", Line %d", line);
fprintf(stdout, "\n");
fprintf(stdout, "%s\n", msgtext);
fflush(stdout);
} else {
fprintf(stdout, "%s\n", msgtext);
fflush(stdout);
}
}

return 0;
}

int
syb_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr,
char *dberrstr, char *oserrstr)
{
if (dberr == SYBESMSG)
return INT_CANCEL;
env_set(g_env, "batch_failcount", "1");
fprintf(stdout,
"DB-LIBRARY error (severity %d, dberr %d, oserr %d,
dberrstr %s, oserrstr %s):\n",
severity, dberr, oserr, dberrstr ? dberrstr : "(null)",
oserrstr ? oserrstr : "(null)");
fflush(stdout);
if ((dbproc == NULL) || DBDEAD(dbproc)) {
if (dberr != SYBECOFL) {
exit(255);
}
}

return INT_CANCEL;
}


int main(int argc, char *argv[])
{
DBPROCESS *dbproc;
LOGINREC *login;
DBINT test_int = 99999999;
DBCHAR test_char[32] = "This is a test";

dbinit();
dberrhandle(syb_err_handler);
dbmsghandle(syb_msg_handler);
login = dblogin();
DBSETLPWD(login, "audit");
DBSETLUSER(login, "audit");
dbproc = dbopen(login, "192.168.58.1");
dbuse(dbproc, "audit_dev");

bcp_init(dbproc,"xxx", (BYTE *)NULL, (BYTE *)NULL, DB_IN);
printf("bcp'ing %s with a length of
%d\n",test_char,strlen(test_char));
//ii = bcp_bind(dbproc, (BYTE *) &test_int, 0, -1, NULL, 0,
SYBINT4, 1 );
//printf("bound %d\n",ii;
bcp_bind(dbproc, test_char, 0, strlen(test_char), NULL, 0,
SYBCHAR, 1 );
bcp_sendrow(dbproc);
printf("sent\n");
bcp_batch(dbproc);
printf("done\n");
return 0;

}
<---------------------------------
_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
--------------------------------------------------------

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







Archive powered by MHonArc 2.6.24.

Top of Page