Re: [HACKERS] How to use the 'char() ' as data type and a function name in the same time.

2014-06-23 Thread Kevin Grittner
rohtodeveloper  wrote:

> When I use the  pg_catalog.char(integer) function  in the
> postgres, I can only use it like these:
> select pg_catalog.char(65);  select "char"(65);
>
> But I want to use the function by the following  way.
> select char(1);

Try using the chr() function.

What you are running into is a result of the fact that besides the
char datatype, PostgreSQL has a "char" datatype, with a completely
different implementation.  While that may not have been the best
decision, there is enough working code that depends on both of
these types that it is unlikely to change.

http://www.postgresql.org/docs/current/interactive/datatype-character.html

Be careful, though; I would not generally recommend the use of
either char or "char" in application tables or code.  The char type
is only included for standard compliance, and has surprising
semantics and generally poorer performance than the alternatives. 
The "char" type is only intended for use in the system catalogs; if
you are considering using it elsewhere, you should consider an enum
instead.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] How to use the 'char() ' as data type and a function name in the same time.

2014-06-23 Thread rohtodeveloper
Dear Hackers
When I use the  pg_catalog.char(integer) function  in the postgres, I can only 
use it like these:select pg_catalog.char(65);  select "char"(65);
But I want to use the function by the following  way.select char(1);Of coures, 
There would be a gram error.
I know the error is caused by that the 'char()' has been defined as one of 
character data types in the 'src\backend\parser\gram.y' file.
However, In SQLServer, the 'char()' can be used as data type and a function 
name in the same time.
For example:---select char(65)  
  > char() used as a function nameA
select cast('1' as char(4)); > char() used as data type---1 

So, I wonder if there is a solution in the postgreSQL to use the char() as data 
type  and function name in the same time like in SQLServer.   
==

Any help appreciated.