Re: BUG #1862: ECPG Connect, host variable trailing blanks

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Jim(dot)Gray(at)Bull(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org, Ken(dot)Rosensteel(at)Bull(dot)com
Subject: Re: BUG #1862: ECPG Connect, host variable trailing blanks
Date: 2005-09-09 03:28:40
Message-ID: 20050909032840.GA69442@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Sep 07, 2005 at 12:06:10PM -0700, Jim(dot)Gray(at)Bull(dot)com wrote:
> According to the documentation at:
> http://www.postgresql.org/docs/8.0/static/ecpg-connect.html
>
> EXEC SQL CONNECT TO :target USER :user;
> The last form makes use of the variant referred to above as character
> variable reference.

The complete text is:

The last form makes use of the variant referred to above as
character variable reference. You will see in later sections how
C variables can be used in SQL statements when you prefix them
with a colon.

Note "C variables" -- it's talking about the C character type, not
the SQL character type.

> To be consistent with other uses of host variables,
> we request that host variables within a connect statement
> act like host variables in DML statements.

They *do* act the same way: the value is passed to the server, which
handles it according to the appropriate type's semantics. If the
host variable's value is used in a CHAR context then trailing spaces
aren't significant in comparisons; if the value is used in other
contexts like VARCHAR, TEXT, or NAME, then trailing spaces *are*
significant. The server makes the decision, not the ECPG preprocessor
or library, which simply passes the value to the server.

If you think this behavior should be changed then propose it on
pgsql-hackers and discuss it with the developers.

--
Michael Fuhr

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2005-09-09 04:15:24 Re: BUG #1862: ECPG Connect, host variable trailing blanks
Previous Message Karim Mardhani 2005-09-09 02:59:48 BUG #1868: Initdb error during silent install on windows 2000