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 Hackers > Re: Auto-update...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 9 Topic 9323 of 10965
Post > Topic >>

Re: Auto-updated fields

by zb@[EMAIL PROTECTED] (Zoltan Boszormenyi) May 8, 2008 at 11:56 AM

Martijn van Oosterhout =EDrta:
> On Wed, May 07, 2008 at 03:04:49PM -0700, David Fetter wrote:
>=20=20=20
>> 1.  Create a generic (possibly overloaded) trigger function, bundled
>> with PostgreSQL, which sets a field to some value.  For example, a
>> timestamptz version might set the field to now().
>>=20=20=20=20=20
>
> Doesn't the SQL standard GENERATED BY functionality work for this? Or
> won't that handle updates?
>=20=20=20

You mean GENERATED ALWAYS AS (expression)?
Yes, they should be updated on every UPDATE as the expression
may include other fields in the same row.

A GENERATED column implemented as a stored column would
work for this but a virtual column would not. A virtual column
would return different values for "now()" in every SELECT.

However we can argue for use cases of a virtual column and implement
it similarly as VIEWs, i.e an ON SELECT rule can expand the original
expression of the column definition.

I suggest using these syntaxes if we decide to implement them:

GENERATED ALWAYS AS (expression) -- SQL standard stored GENERATED column
GENERATED VIRTUAL AS (expression) -- virtual column, obviously

> Have a nice day,
>=20=20=20

Best regards,
Zolt=E1n B=F6sz=F6rm=E9nyi

--=20
----------------------------------
Zolt=E1n B=F6sz=F6rm=E9nyi
Cybertec Sch=F6nig & Sch=F6nig GmbH
http://www.postgresql.at/



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




 9 Posts in Topic:
Auto-updated fields
david@[EMAIL PROTECTED]   2008-05-07 15:04:49 
Re: Auto-updated fields
tgl@[EMAIL PROTECTED] (T  2008-05-08 00:41:38 
Re: Auto-updated fields
kleptog@[EMAIL PROTECTED]  2008-05-08 08:44:46 
Re: Auto-updated fields
zb@[EMAIL PROTECTED] (Zo  2008-05-08 11:56:28 
Re: Auto-updated fields
zb@[EMAIL PROTECTED] (Zo  2008-05-08 12:03:55 
Re: Auto-updated fields
david@[EMAIL PROTECTED]   2008-05-09 06:33:04 
Re: Auto-updated fields
xzilla@[EMAIL PROTECTED]   2008-05-08 11:20:08 
Re: Auto-updated fields
josh@[EMAIL PROTECTED] (  2008-05-08 10:33:26 
Re: Auto-updated fields
hannu@[EMAIL PROTECTED]   2008-05-08 23:40: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 Mon Dec 1 9:27:11 CST 2008.