Re: Virtual generated columns - Mailing list pgsql-hackers

From Marcos Pegoraro
Subject Re: Virtual generated columns
Date
Msg-id CAB-JLwZH-1f1E-idG_oFviRACELhhyAgq+J4m6KUzBNpe6cDGg@mail.gmail.com
Whole thread Raw
In response to Virtual generated columns  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: Virtual generated columns
List pgsql-hackers
Em qua., 8 de jan. de 2025 às 13:14, Peter Eisentraut <peter@eisentraut.org> escreveu:
Here is a new patch version where I have gathered various pieces of
feedback and improvement suggestions that are scattered over this
thread.  I hope I got them all.  I will respond to the respective
messages directly to give my response to each item.

This new version you are not accepting subqueries, like previous ones. But we can create an immutable SQL function which will do the same. Wouldn't it be better to explain that on DOCs ?

create table Orders(Order_ID integer not null primary key, Customer_ID integer references Customer);
create function lkCustomer(integer) returns text language sql immutable as $function$select Name from Customer where Customer_ID = $1;$function$;
alter table Orders add lkCustomer text generated always as (lkCustomer(Customer_ID)) stored;

regards
Marcos

pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: Re: Fwd: Re: A new look at old NFS readdir() problems?
Next
From: Vik Fearing
Date:
Subject: Re: Virtual generated columns