The current method of replacing an existing function with an instrumented uses CREATE OR REPLACE FUNCTION. Since we don't save all the metadata like COST or other attributes, those can be removed on the instrumented version, and won't be restored with piggly untrace. This approach also requires recording parameter names, defaults, and other parts of the function signature so that we can properly redefine the function.
It seems like there's a simpler way to do this, which avoids those problems.
UPDATE pg_proc SET prosrc = '...' WHERE oid = 'snippets(int, int)'::regprocedure;
This preserves any parameter names, cost annotations, and other attributes and might also avoid other problems. Some work is needed to ensure this won't cause other issues. For example, if we only store the OID and the source, what do we do if the UPDATE statement doesn't update any rows (presumably the user replaced the proc since we last looked)?
The current method of replacing an existing function with an instrumented uses
CREATE OR REPLACE FUNCTION. Since we don't save all the metadata likeCOSTor other attributes, those can be removed on the instrumented version, and won't be restored withpiggly untrace. This approach also requires recording parameter names, defaults, and other parts of the function signature so that we can properly redefine the function.It seems like there's a simpler way to do this, which avoids those problems.
This preserves any parameter names, cost annotations, and other attributes and might also avoid other problems. Some work is needed to ensure this won't cause other issues. For example, if we only store the OID and the source, what do we do if the UPDATE statement doesn't update any rows (presumably the user replaced the proc since we last looked)?