Re: Virtual generated columns

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2024-05-22T17:22:47Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Expand virtual generated columns for ALTER COLUMN TYPE

  2. Eliminate code duplication in replace_rte_variables callbacks

  3. Expand virtual generated columns in the planner

  4. Virtual generated columns

  5. Additional tests for stored generated columns

  6. Improve generated_stored test

  7. Fix handling of CREATE DOMAIN with GENERATED constraint syntax

  8. Add pg_constraint rows for not-null constraints

  9. Put generated_stored test objects in a schema

  10. Rename regress test generated to generated_stored

  11. Small code simplification

  12. Remove useless code

  13. Remove useless initializations

  14. doc: Clarify that pg_attrdef also stores generation expressions

  15. Clean out column-level pg_init_privs entries when dropping tables.

  16. Re-implement the ereport() macro using __VA_ARGS__.

Attachments

On 29.04.24 10:23, Peter Eisentraut wrote:
> Here is a patch set to implement virtual generated columns.

> The main feature patch (0005 here) generally works but has a number of 
> open corner cases that need to be thought about and/or fixed, many of 
> which are marked in the code or the tests.  I'll continue working on 
> that.  But I wanted to see if I can get some feedback on the test 
> structure, so I don't have to keep changing it around later.

Here is an updated patch set.  It needed some rebasing, especially 
around the reverting of the catalogued not-null constraints.  I have 
also fixed up the various incomplete or "fixme" pieces of code mentioned 
above.  I have in most cases added "not supported yet" error messages 
for now, with the idea that some of these things can be added in later, 
as incremental features.

In particular, quoting from the commit message, the following are 
currently not supported (but could possibly be added as incremental 
features, some easier than others):

- index on virtual column
- expression index using a virtual column
- hence also no unique constraints on virtual columns
- not-null constraints on virtual columns
- (check constraints are supported)
- foreign key constraints on virtual columns
- extended statistics on virtual columns
- ALTER TABLE / SET EXPRESSION
- ALTER TABLE / DROP EXPRESSION
- virtual columns as trigger columns
- virtual column cannot have domain type

So, I think this basically works now, and the things that don't work 
should be appropriately prevented.  So if someone wants to test this and 
tell me what in fact doesn't work correctly, that would be helpful.