Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Re: now i'm rea...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 21 of 21 Topic 15458 of 17437
Post > Topic >>

Re: now i'm really confused. insert/update does autocast, where sometimes.

by peter_e@[EMAIL PROTECTED] (Peter Eisentraut) May 8, 2008 at 05:26 PM

Am Dienstag, 6. Mai 2008 schrieb Daniel Schuchardt:
> so it depends on ? if i need an explicit cast?

A type cast can be attempted in three different contexts (see also CREATE
CAST 
reference page):

- implicitly
- storage assignment
- explicitly

The explicit case is if you call CAST() or ::.  This is always allowed if
an 
appropriate cast routine is defined.

The implicit case is if an operator or function requires type A and the 
expression is of type B.  This cast is only performed if the cast routine
is 
defined and allowed for the implicit context.  The change in 8.3 was 
to "downgrade" many casting functions from implicit to assignment or 
explicit.

The storage assignment case is if the value has type A and is about to be 
stored into a column of type B.  This is allowed if the cast routine is 
allowed for the assignment context.  This is, perhaps surprisingly, a 
separate level between implicit and explicit casts.  So in reference to
your 
subject line, yes, INSERT and UPDATE do have different casting behavior
than 
SELECT.  (This is not really accurate, because the WHERE clause of an
UPDATE 
would follow the same rules as a WHERE clause in SELECT.  The assignment 
context only applies for values that are really going to be stored.)

This is all in line with the SQL standard.

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




 21 Posts in Topic:
operator varchar = integer
Daniel Schuchardt <dan  2008-05-05 11:18:37 
Re: operator varchar = integer
Daniel Schuchardt <dan  2008-05-05 12:55:25 
Re: operator varchar = integer
laurenz.albe@[EMAIL PROTE  2008-05-05 14:44:02 
Re: operator varchar = integer
david@[EMAIL PROTECTED]   2008-05-05 07:33:30 
Re: operator varchar = integer
Daniel Schuchardt <dan  2008-05-05 17:26:40 
Re: operator varchar = integer
david@[EMAIL PROTECTED]   2008-05-05 08:52:54 
Re: operator varchar = integer
Daniel Schuchardt <dan  2008-05-05 18:53:20 
Re: operator varchar = integer
tgl@[EMAIL PROTECTED] (T  2008-05-05 13:36:01 
Re: operator varchar = integer
Daniel Schuchardt <dan  2008-05-05 21:04:41 
Re: operator varchar = integer
Daniel Schuchardt <dan  2008-05-05 18:32:37 
operator is not unique: integer || integer
Daniel Schuchardt <dan  2008-05-05 18:43:37 
Re: operator is not unique: integer || integer
Daniel Schuchardt <dan  2008-05-05 20:54:07 
Re: operator is not unique: integer || integer
daniel_schuchardt@[EMAIL   2008-05-05 21:36:51 
Re: operator is not unique: integer || integer
kgore4@[EMAIL PROTECTED]   2008-05-06 10:05:18 
Re: operator is not unique: integer || integer
Daniel Schuchardt <dan  2008-05-06 10:08:06 
Re: operator is not unique: integer || integer
dalroi@[EMAIL PROTECTED]   2008-05-06 08:36:46 
Re: operator is not unique: integer || integer
Daniel Schuchardt <dan  2008-05-06 10:33:37 
now i'm really confused. insert/update does autocast, where some
Daniel Schuchardt <dan  2008-05-06 11:31:55 
Re: now i'm really confused. insert/update does autocast, where
Daniel Schuchardt <dan  2008-05-06 11:56:17 
Re: now i'm really confused. insert/update does autocast, where
kleptog@[EMAIL PROTECTED]  2008-05-06 13:16:30 
Re: now i'm really confused. insert/update does autocast, where
peter_e@[EMAIL PROTECTED]  2008-05-08 17:26:17 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 12:24:31 CST 2008.