[freetds] freebcp out from MS SQL Server drops spaces [NC]

Cedric ROUVRAIS cedric.rouvrais at sgcib.com
Thu Jul 9 10:35:47 EDT 2009


Hi,

Sent the source code to you and James.

In a nutshell, at the end of bcp::_bcp_exec_out inserted two segments:

                              /**
                               * Per ANSI Spec for fixed width character
columns, pad with spaces
                               * It would be more efficient to not trim the
data provided by the database, but that
                               * requires more extensive code change above.
                               */
                              if ((curcol->column_type == SYBCHAR) &&
(buflen < curcol->column_size)) {
                                    int pad;
                                    for (pad = buflen; pad <
curcol->column_size; pad++) {
                                          written = fwrite(" ", 1, 1,
hostfile);
                                          if (written < 1) {
                                                dbperror(dbproc, SYBEBCWE,
errno);
                                                return FAIL;
                                          }
                                    }
                              }

and

                  /** Output some progres information like Sybase BCP does
*/
                  if (rows_written % 1000 == 0) {
                        printf("%d rows successfully bulk-copied to
host-file.\n", rows_written);
                  }


In the freebcp.c source code added : after t: to make it an optional
argument option.

      while ((ch = getopt(argc, argv,
"m:f:e:F:L:b:t::r:U:P:I:S:h:T:A:O:0:ncEdvV")) != -1) {

Changed the case processing segment to

            case 't':
                  pdata->tflag++;
                  if (optarg == NULL) {
                        pdata->fieldterm = '\0';
                        pdata->fieldtermlen = 0;
                  } else {
                        pdata->fieldterm = strdup(optarg);
                        pdata->fieldtermlen = unescape(pdata->fieldterm);
                  }
                  break;

And replaced
            if (!pdata->tflag || !pdata->fieldterm) {  /* field terminator
not specified */
With
            if (!pdata->tflag) {     /* field terminator not specified */

a++ Cedric



|------------------------------                                            
|            Frediano Ziglio                                               
|            <freddy77 at gmail.c                                             
|            om>                                                           
|            Sent by:                                                      
|            freetds-bounces at l                                             
|            ists.ibiblio.org                                              
|                                                                          
|                                                                          
|            07/09/2009 09:26                                              
|            AM                                                            
|                                                                          
|                                                                          
|            Please respond to                                             
|                 FreeTDS                                                  
|            Development Group                                             
|            <freetds at lists.ib                                             
|               iblio.org>                                                 
|                                                                          
|                                                                          
                                                                           
                                                                           
                                                                        To 
                                               FreeTDS Development Group   
                                               <freetds at lists.ibiblio.org> 
                                                                        cc 
                                                                           
                                                                   Subject 
                                               Re: [freetds] freebcp out   
                                               from MS SQL Server drops    
                                               spaces [NC]                 
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




2009/7/9 Cedric ROUVRAIS <cedric.rouvrais at sgcib.com>:
> Hi Frediano,
>
> I am not a vendor, just a simple first time user.
>
> a++ Cedric
>
>

I know, but you reported a misbehavior between FreeTDS and Microsoft
application

freddy77
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds



*************************************************************************
This message and any attachments (the "message") are confidential, intended 
solely for the addressee(s), and may contain legally privileged information.  
Any unauthorised use or dissemination is prohibited.  E-mails are susceptible 
to alteration.  Neither SOCIETE GENERALE nor any of its subsidiaries or 
affiliates shall be liable for the message if altered, changed or falsified.
*************************************************************************



More information about the FreeTDS mailing list