character datatype explaination sought

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

character datatype explaination sought

byrnejb
I am testing Idempiere and have run across this in an example:

character(1) DEFAULT 'Y'::bpchar NOT NULL,

How does this differ from

character(1) DEFAULT 'Y' NOT NULL,



--
***          e-Mail is NOT a SECURE channel          ***
        Do NOT transmit sensitive data via e-Mail
   Unencrypted messages have no legal claim to privacy
 Do NOT open attachments nor follow links sent by e-Mail

James B. Byrne                mailto:[hidden email]
Harte & Lyne Limited          http://www.harte-lyne.ca
9 Brockley Drive              vox: +1 905 561 1241
Hamilton, Ontario             fax: +1 905 561 0757
Canada  L8E 3C3



Reply | Threaded
Open this post in threaded view
|

Re: character datatype explaination sought

Tom Lane-2
"James B. Byrne" <[hidden email]> writes:
> I am testing Idempiere and have run across this in an example:
> character(1) DEFAULT 'Y'::bpchar NOT NULL,

> How does this differ from

> character(1) DEFAULT 'Y' NOT NULL,

It doesn't.  The former is just written with an explicit cast,
which the latter lacks, but the end result will be the same
because the parser will coerce the DEFAULT expression to the
column's type anyway.

(It helps to know that for reasons lost in the depths of time,
Postgres' internal name for the char(N) type is "bpchar".)

                        regards, tom lane


Reply | Threaded
Open this post in threaded view
|

Re: character datatype explaination sought

Laurenz Albe
In reply to this post by byrnejb
On Thu, 2020-10-15 at 10:07 -0400, James B. Byrne wrote:
> I am testing Idempiere and have run across this in an example:
>
> character(1) DEFAULT 'Y'::bpchar NOT NULL,
>
> How does this differ from
>
> character(1) DEFAULT 'Y' NOT NULL,

It is the same, only in the first version the type cast is explicit.

Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com



Reply | Threaded
Open this post in threaded view
|

Re: character datatype explaination sought

Adrian Klaver-4
In reply to this post by byrnejb
On 10/15/20 7:07 AM, James B. Byrne wrote:
> I am testing Idempiere and have run across this in an example:
>
> character(1) DEFAULT 'Y'::bpchar NOT NULL,
>
> How does this differ from
>
> character(1) DEFAULT 'Y' NOT NULL,

It doesn't. From here:

https://www.postgresql.org/docs/current/typeconv-query.html

"...  bpchar (“blank-padded char”, the internal name of the character
data type) ..."

>
>
>


--
Adrian Klaver
[hidden email]