Re: BUG #1862: ECPG Connect, host variable trailing blanks - Mailing list pgsql-bugs

From Michael Fuhr
Subject Re: BUG #1862: ECPG Connect, host variable trailing blanks
Date
Msg-id 20050909032840.GA69442@winnie.fuhr.org
Whole thread Raw
In response to Re: BUG #1862: ECPG Connect, host variable trailing blanks  (Jim.Gray@Bull.com)
Responses Re: BUG #1862: ECPG Connect, host variable trailing blanks  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On Wed, Sep 07, 2005 at 12:06:10PM -0700, Jim.Gray@Bull.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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: ia64-hp-hpux11.23 configure warnings
Next
From: Tom Lane
Date:
Subject: Re: BUG #1862: ECPG Connect, host variable trailing blanks