Re: Stored procedure code no longer stored in v14 and v15, changed behaviour - Mailing list pgsql-general

From Alban Hertroys
Subject Re: Stored procedure code no longer stored in v14 and v15, changed behaviour
Date
Msg-id F472845F-DED3-4E7E-94DE-F4C65A1EECAA@gmail.com
Whole thread Raw
In response to Re: Stored procedure code no longer stored in v14 and v15, changed behaviour  (DAVID ROTH <adaptron@comcast.net>)
Responses Aw: Re: Stored procedure code no longer stored in v14 and v15, changed behaviour
List pgsql-general
> On 2 Dec 2022, at 15:10, DAVID ROTH <adaptron@comcast.net> wrote:
>
> Is there a way to reverse engineer the original code (or its equivalent) from what is saved in the database?

I’m dumping an idea here… Treading back quite a bit with information from later in this thread.

With the original procedure source code under version control and assuming the tokenization converts that source code
consistently(since it’s done by a computer), you could store another level of diffs: From the source code you pushed,
againstthe output of pg_get_functiondef. 

Assuming that changes to the tokenised code, when converted back to text, only involve renames of database objects, the
resultof a reversely applied diff could very well be comparable to the original source code. 

I suspect that would be sufficient for telling whether a developer is responsible for the changes, or that they were
causedby renaming of database artefacts. 

You would need to wrap the function creation calls into some automation to generate and store those diffs, comparing it
back,etc, but that may be doable. I would also generate new diffs right after major version updates of the database (a
beforeand after of the output of pg_get_functiondef, applied to the stored diff?). 

I’m not so sure that would work for auditing, but that seems to have been tackled down-thread.

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.




pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Views "missing" from information_schema.view_table_usage
Next
From: Tom Lane
Date:
Subject: Re: print in plpython not appearing in logs