Search Postgresql Archives

Re: Re: Where is the char and varchar length in pg_catalog for function input variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"David Johnston" <polobo@xxxxxxxxx> wrote:
 
> If you want to guarantee that the INSERT will work you would need
> to write:
> 
> INSERT INTO test_table VALUES ( $1::char(10), $2::varchar(20) )
 
Note that this will quietly cut off the tail end of the supplied
data, so it should only be used when that is desirable.  It is
generally better to throw an error than to lose data.
 
> whether "char" and "varchar" differ in their behavior in this
> respect I do not know.
 
Per the SQL standard, they both throw an error on attempts to assign
an oversized value, but allow truncation through explicit casts.
 
> It is generally not recommended to use "char"
 
Right.  It is supported because the standard specifies it and its
behavior, but the semantics of char(n) are weird and the
performance, in PostgreSQL, is generally worse for char(n) than
varchar(n) or text.
 
-Kevin


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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux