Skip to Content.
Sympa Menu

freetds - Re: large queries and TDS 7.0

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Brian Bruns <camber AT ais.org>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: large queries and TDS 7.0
  • Date: Wed, 18 Oct 2000 22:35:28 -0400 (EDT)


Hi Brandon,

Thanks for taking on of my long overdue TODO items :-)

It looks great. I've just committed the patch to the CVS tree so it should
be there in a few.

Brian

On Wed, 18 Oct 2000, Brandon M. Reynolds wrote:

> Thanks Brian. That does solve my problem with large queries, but
> only with ctlib. I created a patch for making the dbbuf dynamic
> in the DBPROCESS structure. Would you pretty please apply this
> patch so that long queries work with dblib too?
>
> diff -urN freetds/include/sybdb.h freetds.10182000/include/sybdb.h
> --- freetds/include/sybdb.h Sat Oct 7 15:32:32 2000
> +++ freetds.10182000/include/sybdb.h Wed Oct 18 09:01:02 2000
> @@ -150,7 +150,8 @@
> int noautofree;
> int more_results; /* boolean. Are we expecting results? */
> BYTE *user_data; /* see dbsetuserdata() and dbgetuserdata()
> */
> - unsigned char dbbuf[8192]; /* XXX should be dynamic
> */
> + unsigned char *dbbuf; /* is dynamic! */
> + int dbbufsz;
> int empty_res_hack;
> TDS_INT text_size;
> TDS_INT text_sent;
> diff -urN freetds/src/dblib/dblib.c freetds.10182000/src/dblib/dblib.c
> --- freetds/src/dblib/dblib.c Sun Oct 8 22:19:09 2000
> +++ freetds.10182000/src/dblib/dblib.c Wed Oct 18 09:17:22 2000
> @@ -449,8 +449,9 @@
> }
>
> dbproc->tds_socket = (void *) tds_connect(login->tds_login);
> - dbproc->dbbuf[0]='\0'; /* initialize query buffer */
> -
> + dbproc->dbbuf = NULL;
> + dbproc->dbbufsz = 0;
> +
> if(dbproc->tds_socket) {
> tds_set_parent( dbproc->tds_socket, dbproc);
> tds_add_connection(g_tds_context, dbproc->tds_socket);
> @@ -465,9 +466,26 @@
> }
> RETCODE dbcmd(DBPROCESS *dbproc, char *cmdstring)
> {
> - /* here is one of those large static buffers that should be malloced
> - ** but in the interest of time i kludged :) */
> - strcat(dbproc->dbbuf,cmdstring);
> + if(dbproc->dbbufsz == 0) {
> + if((dbproc->dbbuf =
> + (unsigned char *)malloc(strlen(cmdstring)+1)) ==
> NULL) {
> + return FAIL;
> + }
> + strcpy(dbproc->dbbuf,cmdstring);
> + dbproc->dbbufsz = strlen(cmdstring) + 1;
> + } else {
> + int newsz;
> + void *p;
> +
> + newsz = strlen(cmdstring) + dbproc->dbbufsz;
> + if((p=realloc(dbproc->dbbuf,newsz)) == NULL) {
> + return FAIL;
> + }
> + dbproc->dbbuf = (unsigned char *)p;
> + strcat(dbproc->dbbuf,cmdstring);
> + dbproc->dbbufsz = newsz;
> + }
> +
> return SUCCEED;
> }
> RETCODE dbsqlexec(DBPROCESS *dbproc)
> @@ -534,6 +552,7 @@
> }
> free(dbproc->bcp_columns);
> }
> + dbfreebuf(dbproc);
>
> free(dbproc);
> tds_del_connection(g_tds_context, dbproc->tds_socket);
> @@ -1618,7 +1637,11 @@
>
> void dbfreebuf(DBPROCESS *dbproc)
> {
> - dbproc->dbbuf[0] = '\0';
> + if(dbproc->dbbuf) {
> + free(dbproc->dbbuf);
> + dbproc->dbbuf = NULL;
> + }
> + dbproc->dbbufsz = 0;
> } /* dbfreebuf() */
>
> RETCODE dbclropt(DBPROCESS *dbproc,int option, char *param)
> @@ -1895,7 +1918,7 @@
> }
> if (! dbproc->noautofree)
> {
> - dbproc->dbbuf[0]='\0';
> + dbfreebuf(dbproc);
> }
> result = SUCCEED;
> }
>
>
> Brandon M. Reynolds Ph: (330) 644-3059
> Systems Engineer Fax: (330) 644-8110
> Commercial Timesharing Inc. Email: bmr AT comtime.com
>
>





Archive powered by MHonArc 2.6.24.

Top of Page