Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJI0p-0004iA-Ni for pgsql-novice@arkaria.postgresql.org; Fri, 18 Sep 2020 15:09:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kJI0l-0007D9-Mz for pgsql-novice@arkaria.postgresql.org; Fri, 18 Sep 2020 15:09:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kJI0k-0007Bl-T4 for pgsql-novice@lists.postgresql.org; Fri, 18 Sep 2020 15:09:19 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kJI0e-0006bF-3C for pgsql-novice@lists.postgresql.org; Fri, 18 Sep 2020 15:09:17 +0000 Received: by mail-wm1-x32c.google.com with SMTP id z9so5925350wmk.1 for ; Fri, 18 Sep 2020 08:09:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=bqzyD7tPSHnKTwDDGPt1gKv8+ZiC51oIA+LF+/7VqeQ=; b=JSFrB08sTpUIh3h8lpjrZS5yR3dSIpBR5CekVcWFwJ9zSUoOYc4Vu89mev8dW+D7oO TkdUhvQrUsg72EAFsIofMppsfH72Xkwd2E7UV/is/3UkBtpnr/m+O6QPL3Bbkwu1iMGd wtEMb4RDuVqPWGWaDJSjh/LXAqm22ax1OPDqz5PuIyI9LGor3+/aFqcyao1aFgj+tauB BdgHxR0V/Ij5mPHaMnXFjsULLqHKQR9jFMNX1pW7m4ebaPXGeTBNiEYYboNNvwEH4E5o 2nzYfzxXlCfG+BpqBuRJW/3GP/x1vEfm/avNirTnDBu2oXnGHuCPZ+ZB4y54QTNBbSW4 GNsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=bqzyD7tPSHnKTwDDGPt1gKv8+ZiC51oIA+LF+/7VqeQ=; b=Gwn6qXEcaoBl3oCeXGSN9cLRxPLzi4aioOQehYUZTiOsYuBirolgK71Sm5Td2TfSs+ 2kB8Yjci/EXggWostgmH+Z6iUt7n8kL9c4ESxz2M9U0xmn9BuNe/CLL50mV+aTZok9Ju PNUiWS/QzwtHgQkcs/e2pPlmU5bjTdA43hb+Jsa6lxeb7o8eReucNoRg4R16tmOh/AKe HLjx/htEjW+uSoVLokxEDARIpdrcAeSJedbiNSicb5EkHbHIosvTtvUsU1fuB+LQwySY wcWaBBu0/QSG5b/SpRf6fr8RBA5XHrgh4R+c978ZjakU9jw1rBuN89gcLb1EfEnXNPNG i2Gg== X-Gm-Message-State: AOAM533cVIV3xsceQtjdvhc0FS0anxeiBsxD0XU7DxFfWyGXhjHIi+51 a5eHieEAThmMIKL6GN5YJ74MDg== X-Google-Smtp-Source: ABdhPJxO8xNVE0l72+z9C0JC3DAH0uoNK3i3DdzeVhqtawhBneaC41u1DOGLXbkvhmVYpw8TO2sBSw== X-Received: by 2002:a7b:c151:: with SMTP id z17mr16924884wmi.53.1600441750154; Fri, 18 Sep 2020 08:09:10 -0700 (PDT) Received: from localhost.localdomain (217-149-168-95.nat.highway.telekom.at. [217.149.168.95]) by smtp.gmail.com with ESMTPSA id k5sm5515120wmb.19.2020.09.18.08.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 08:09:09 -0700 (PDT) Message-ID: <4501de283bdb6aa598f733549b69fbf9a92b8c0c.camel@cybertec.at> Subject: Re: New Data Type Implementation From: Laurenz Albe To: Franz Hofer , pgsql-novice@lists.postgresql.org Date: Fri, 18 Sep 2020 17:09:08 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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