public inbox for [email protected]  
help / color / mirror / Atom feed
From: Laurenz Albe <[email protected]>
To: Franz Hofer <[email protected]>
To: [email protected]
Subject: Re: New Data Type Implementation
Date: Fri, 18 Sep 2020 17:09:08 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <trinity-d9d814f4-9dc1-4f16-ab89-d4d27078e392-1600361320157@3c-app-gmx-bs32>
References: <trinity-d9d814f4-9dc1-4f16-ab89-d4d27078e392-1600361320157@3c-app-gmx-bs32>

On Thu, 2020-09-17 at 18:48 +0200, Franz Hofer wrote:
> I am trying to implement a way (either a new data type (base or composite) or creating C-functions)
>  that allow a type to modify the stored data after a specified amount of time.
> 
> [...]
>   
> An example of all this would be:
> A "Person" table storing the first and last name as column. (For a survey)
> While creating the table, the user selects the above mentioned type as types for the columns.
>  Additionally to the type the user has to specify how long that data should be stored / or is valid.
> After the survey is finished (=> or the set date is reached) the data type / logic / or something
>  would take care of that and overwrite or reset the values or mark them as invalid.

A data type cannot modify its data, there has to be some process that would do that.
I don't think a data type is the right approach.

I would simply do that when the data are queried, something like

SELECT CASE WHEN expiry_date < current_timestamp THEN NULL::integer ELSE intvalue END
FROM ...

Additionally, you can run a regular clean-up job that deletes or updates expired data,
if you need to physically delete them.

Yours,
Laurenz Albe
-- 
+43-670-6056265
CYBERTEC PostgreSQL International GmbH
Gröhrmühlgasse 26, A-2700 Wiener Neustadt
Web: https://www.cybertec-postgresql.com






view thread (2+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: New Data Type Implementation
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox