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

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

\n converted to \r\n

От
Amir Zicherman
Дата:
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



PS: This is a mailing list thread I ran across that had the same
problem.  does anybody know if the bug has been fixed? 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

От
Jeff Eckermann
Дата:
--- Amir Zicherman <amir.zicherman@gmail.com> wrote:

> 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?

I don't believe that there is any user-settable option
to disable that functionality.  The driver assumes
that the returned value will (or may) be required for
display, so on Windows, \r\n is the appropriate
combination.  No doubt this makes sense 99.9% of the
time.

Perhaps if you could tell us what it is that you are
trying to do, someone on the list can suggest a
workaround that will do the job for you.

>
> Thanx in advance for your help, amir
>
>
>
> PS: This is a mailing list thread I ran across that
> had the same
> problem.  does anybody know if the bug has been
> fixed? 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
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>




_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

Re: \n converted to \r\n

От
"Trewern, Ben"
Дата:

There's a setting on page 2 of the Advanced options of the Windows driver applet which says:

LF <-> CR/LF conversion

Seems like a good place to start ;)

Ben

> -----Original Message-----
> From: Jeff Eckermann [mailto:jeff_eckermann@yahoo.com]
> Sent: 01 October 2004 14:57
> To: Amir Zicherman; pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] \n converted to \r\n
>
>
> --- Amir Zicherman <amir.zicherman@gmail.com> wrote:
>
> > 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?
>
> I don't believe that there is any user-settable option
> to disable that functionality.  The driver assumes
> that the returned value will (or may) be required for
> display, so on Windows, \r\n is the appropriate
> combination.  No doubt this makes sense 99.9% of the
> time.
>
> Perhaps if you could tell us what it is that you are
> trying to do, someone on the list can suggest a
> workaround that will do the job for you.
>

***********************************************************************
This email and any attachments transmitted with it are confidential
and intended solely for the use of the individual or entity to whom
they are addressed. If you have received this email in error please
notify the sender and do not store, copy or disclose the content
to any other person.

It is the responsibility of the recipient to ensure that opening this
message and/or any of its attachments will not adversely affect
its systems. No responsibility is accepted by the Company.
***********************************************************************

Re: \n converted to \r\n

От
"Dave Page"
Дата:

> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Jeff Eckermann
> Sent: 01 October 2004 14:57
> To: Amir Zicherman; pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] \n converted to \r\n
>
> I don't believe that there is any user-settable option to
> disable that functionality.

There is an 'LF <-> CR/LF Conversion' option on the second options
dialog.

Regards, Dave

Re: \n converted to \r\n

От
Amir Zicherman
Дата:
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


On Fri, 1 Oct 2004 15:10:10 +0100, Dave Page <dpage@vale-housing.co.uk> wrote:
>
>
> > -----Original Message-----
> > From: pgsql-odbc-owner@postgresql.org
> > [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Jeff Eckermann
> > Sent: 01 October 2004 14:57
> > To: Amir Zicherman; pgsql-odbc@postgresql.org
> > Subject: Re: [ODBC] \n converted to \r\n
> >
> > I don't believe that there is any user-settable option to
> > disable that functionality.
>
> There is an 'LF <-> CR/LF Conversion' option on the second options
> dialog.
>
> Regards, Dave
>

Re: \n converted to \r\n

От
"Greg Campbell"
Дата:
If you are using a sufficiently up-to-date windows machine, you can make
the tools available on it tell you. I'm not sure if this requires VB or
Studio,.. but here goes.

1.Create a DSN entry to your database.

2. On your desktop create a new file -- text if fine.
3. Save or Rename the file to test.udl -- don't worry when it barks
about changing the file extension or association.
4. Right click on test.udl and choose open. It will open a wizard to
help you form an datasource connection string. You may have to choose
that you wish to use connection string. All the options available to
your ODBC driver will be placed into a string.

When the wizard is complete, open the udl file with notepad -- or drag
and drop it onto a Notepad shortcut to open it.

To your specific question the option parameter is
LFConversion=0  for no
LFConversion=1  for yes


Amir Zicherman wrote:

>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
>
>
>On Fri, 1 Oct 2004 15:10:10 +0100, Dave Page <dpage@vale-housing.co.uk> wrote:
>
>
>>
>>
>>>-----Original Message-----
>>>From: pgsql-odbc-owner@postgresql.org
>>>[mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Jeff Eckermann
>>>Sent: 01 October 2004 14:57
>>>To: Amir Zicherman; pgsql-odbc@postgresql.org
>>>Subject: Re: [ODBC] \n converted to \r\n
>>>
>>>I don't believe that there is any user-settable option to
>>>disable that functionality.
>>>
>>>
>>There is an 'LF <-> CR/LF Conversion' option on the second options
>>dialog.
>>
>>Regards, Dave
>>
>>
>>
>
>---------------------------(end of broadcast)---------------------------
>TIP 8: explain analyze is your friend
>
>

Вложения

Connection Pooling

От
Max Cohan
Дата:
Does anyone know if there is a way to do selective connection
pooling with ODBC. That is, most of the connections in my application
can be safely pooled. However, there are a couple of specific ones where
I use temp. tables...

Can I specify which connections are out of the pool and which are
'fresh'? Or do I have to develop my own pooling solution?

Specifically, I am using VB.NET and the ODBC provider for .NET to
the PgSQL ODBC driver.

Thanks,
Max

Re: \n converted to \r\n

От
Amir Zicherman
Дата:
Awesome, it works!  i dig the method of using the udl file to show all
available connection string properties.  thanx a lot for your help.

amir


On Fri, 01 Oct 2004 13:50:32 -0400, Greg Campbell
<greg.campbell@us.michelin.com> wrote:
> If you are using a sufficiently up-to-date windows machine, you can make
> the tools available on it tell you. I'm not sure if this requires VB or
> Studio,.. but here goes.
>
> 1.Create a DSN entry to your database.
>
> 2. On your desktop create a new file -- text if fine.
> 3. Save or Rename the file to test.udl -- don't worry when it barks
> about changing the file extension or association.
> 4. Right click on test.udl and choose open. It will open a wizard to
> help you form an datasource connection string. You may have to choose
> that you wish to use connection string. All the options available to
> your ODBC driver will be placed into a string.
>
> When the wizard is complete, open the udl file with notepad -- or drag
> and drop it onto a Notepad shortcut to open it.
>
> To your specific question the option parameter is
> LFConversion=0  for no
> LFConversion=1  for yes
>
>
>
>
> Amir Zicherman wrote:
>
> >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
> >
> >
> >On Fri, 1 Oct 2004 15:10:10 +0100, Dave Page <dpage@vale-housing.co.uk> wrote:
> >
> >
> >>
> >>
> >>>-----Original Message-----
> >>>From: pgsql-odbc-owner@postgresql.org
> >>>[mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Jeff Eckermann
> >>>Sent: 01 October 2004 14:57
> >>>To: Amir Zicherman; pgsql-odbc@postgresql.org
> >>>Subject: Re: [ODBC] \n converted to \r\n
> >>>
> >>>I don't believe that there is any user-settable option to
> >>>disable that functionality.
> >>>
> >>>
> >>There is an 'LF <-> CR/LF Conversion' option on the second options
> >>dialog.
> >>
> >>Regards, Dave
> >>
> >>
> >>
> >
> >---------------------------(end of broadcast)---------------------------
> >TIP 8: explain analyze is your friend
> >
> >
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
>
>
>
>