Обсуждение: \n converted to \r\n

Поиск
Список
Период
Сортировка

\n converted to \r\n

От
amir
Дата:

Hello,

 

I’m currently running version 07_03_0200 of the Insight Distribution Systems PostgreSQL Driver for windows.  when I retrieve col1 string from the database using:  “SELECT * FROM MyTable WHERE col1=’hello\n’”  the value returned for col1 through the driver is “hello\r\n”, and I want it to be as it is stored in the database (‘hello\n” with no \r).  Is this a configuration issue?  If so, where can I change the configuration to ensure that this conversion won’t happen? 

 

Thanx in advance for your help, amir

 

 

This is a mailing list thread I ran across that had the same problem.  I tried contacting Byron, but his email is no longer valid: 

 

Date: Fri, 09 Apr 1999 18:46:00 -0400
From: Byron Nikolaidis <byronn@insightdist.com>
Subject: Re: [INTERFACES] ODBC Driver v06-40-0005
 
Sam O'Connor wrote:
 
> Hi,
> I think I found another problem.
> When selecting type text from tclodbc using pgodbc and postgres I was
> loosing
> one character off the start of the string for every newline in
> contained.
> When copy_and_conver_field processes selected text fields it converts cr
> to cr/lf. (why?)
 
Actually, its LF to CR/LF when going from the database to odbc.  When going the
other way (odbc->database), it converts CR/LF to LF.   The reason is for
Microsoft from what I remember.  It might have even been in the odbc spec (I
can't quite remember).   It probably shouldn't do it if its being run on Unix
though?
 
> When data_left is set how ever it uses the original length.
> I changed this:
>         stmt->bindings[stmt->current_col].data_left = strlen(value);
> To this:
>         stmt->bindings[stmt->current_col].data_left = strlen(ptr);
> Now it works!
 
Good Job, you found a bug alright!   It should be strlen(ptr).  When I tested
it, I didn't have newlines so it worked ok.
 
I'll put it in for the next release.
 
Byron

 

 

Re: \n converted to \r\n

От
"Dave Page"
Дата:

> -----Original Message-----
> From: Amir Zicherman [mailto:amir.zicherman@gmail.com]
> Sent: 01 October 2004 18:27
> To: Dave Page
> Cc: Jeff Eckermann; ben.trewern@mowlem.com; pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] \n converted to \r\n
>
> Hi, thax for your help.  Took me a while to see where the
> configuration options are because i'm not using a DSN.  I
> then put in a DSN to see if it comes with configuration
> options and found what you guys were talking about.  If i'm
> just using a connection string in my code, is there any way
> to configure this option?  My code needs to be more generic
> than to rely on me settign up DSNs for each database i want
> to connect to.  This is what i'm using to connect in the code:
>
> "DRIVER={" + DB_DRIVER +
>     "};DATABASE=" + dbName_ +
>     ";SERVER=" + dbIP_ +
>     ";PORT=" + dbPort_ +
>     ";UID=" + dbUser_ +
>     ";PWD=" + dbPassword_;
>
> thanx, amir

The easy way to get the connection string is to create a DSN with the
settings you want, switch on the commlog and then connect. The resulting
logfile will show you the full connection string built.

In pgAdmin II which used ODBC, we used to use the following:

DRIVER={PostgreSQL};READONLY=0;PROTOCOL=6.4;FAKEOIDINDEX=0;SHOWOIDCOLUMN
=0;ROWVERSIONING=0;SHOWSYSTEMTABLES=0;CONNSETTINGS=;FETCH=100;SOCKET=409
6;UNKNOWNSIZES=0;MAXVARCHARSIZE=254;MAXLONGVARCHARSIZE=65536;OPTIMIZER=1
;KSQO=1;USEDECLAREFETCH=0;TEXTASLONGVARCHAR=1;UNKNOWNSASLONGVARCHAR=0;BO
OLSASCHAR=1;PARSE=0;CANCELASFREESTMT=0;EXTRASYSTABLEPREFIXES=dd_;

Obviously we would add the database, server, username, password and port
options to that.

Regards,Dave.

Re: \n converted to \r\n

От
Amir Zicherman
Дата:
even simpler, thanx dave.


On Fri, 1 Oct 2004 21:11:33 +0100, Dave Page <dpage@vale-housing.co.uk> wrote:
>
>
> > -----Original Message-----
> > From: Amir Zicherman [mailto:amir.zicherman@gmail.com]
> > Sent: 01 October 2004 18:27
> > To: Dave Page
> > Cc: Jeff Eckermann; ben.trewern@mowlem.com; pgsql-odbc@postgresql.org
> > Subject: Re: [ODBC] \n converted to \r\n
> >
> > Hi, thax for your help.  Took me a while to see where the
> > configuration options are because i'm not using a DSN.  I
> > then put in a DSN to see if it comes with configuration
> > options and found what you guys were talking about.  If i'm
> > just using a connection string in my code, is there any way
> > to configure this option?  My code needs to be more generic
> > than to rely on me settign up DSNs for each database i want
> > to connect to.  This is what i'm using to connect in the code:
> >
> > "DRIVER={" + DB_DRIVER +
> >       "};DATABASE=" + dbName_ +
> >       ";SERVER=" + dbIP_ +
> >       ";PORT=" + dbPort_ +
> >       ";UID=" + dbUser_ +
> >       ";PWD=" + dbPassword_;
> >
> > thanx, amir
>
> The easy way to get the connection string is to create a DSN with the
> settings you want, switch on the commlog and then connect. The resulting
> logfile will show you the full connection string built.
>
> In pgAdmin II which used ODBC, we used to use the following:
>
> DRIVER={PostgreSQL};READONLY=0;PROTOCOL=6.4;FAKEOIDINDEX=0;SHOWOIDCOLUMN
> =0;ROWVERSIONING=0;SHOWSYSTEMTABLES=0;CONNSETTINGS=;FETCH=100;SOCKET=409
> 6;UNKNOWNSIZES=0;MAXVARCHARSIZE=254;MAXLONGVARCHARSIZE=65536;OPTIMIZER=1
> ;KSQO=1;USEDECLAREFETCH=0;TEXTASLONGVARCHAR=1;UNKNOWNSASLONGVARCHAR=0;BO
> OLSASCHAR=1;PARSE=0;CANCELASFREESTMT=0;EXTRASYSTABLEPREFIXES=dd_;
>
> Obviously we would add the database, server, username, password and port
> options to that.
>
> Regards,Dave.
>