I am new to PostgreSQL (currently working with MSSQL). Lets assume we have a composite type Customer(uid uuid, name text)
and you choose to return this type from your functions (procedures) like:
create or replace function public.getCustomers(value text)
returns setof Customer as
$$
select "uid", "name", from "Common_Customer";
$$
language sql;
Everything works and there is no pain, but suddenly you figure out that customer also needs a lastname
property to be returned from database.
So you alter the customer type to add an attribute lastname
, and that's where the trouble begins. I figured out that I can easily add an attribute to the Customer
type, but all functions using it break because they are missing the newly added attribute lastname
and there are no default for composite type attributes.
What do you guys do in such a situation? Do you first find all functions using that type, write a query to replace them, then alter the type and replace all the functions in one commit?
In MSSQL there are no types (and you are not forced to tell which type the procedure must return), stored procedures can return exactly what you want them to (which is a problem sometimes). So I am a little blank here.