pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alban Hertroys <haramrae@gmail.com>
To: DAVID ROTH <adaptron@comcast.net>
Cc: Dominique Devienne <ddevienne@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Christophe Pettus <xof@thebuild.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: Martijn Tonies (Upscene Productions) <m.tonies@upscene.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Stored procedure code no longer stored in v14 and v15, changed behaviour
Date: Sat, 3 Dec 2022 12:23:17 +0100
Message-ID: <F472845F-DED3-4E7E-94DE-F4C65A1EECAA@gmail.com> (raw)
In-Reply-To: <1258414512.930087.1669990257195@connect.xfinity.com>
References: <23DE96C56DFC404096553A22DDC5093B@MARTIJNWS>
	<CAKFQuwbYCk0oA3VT+ngEebBTBjdtGsVLEFOdPX2qqQJobA7rtg@mail.gmail.com>
	<1579912.1669908194@sss.pgh.pa.us>
	<CAFCRh--K2tahGetbJ_mtjiwvfFb9fF6SzjGnvbyoMKPr92FiTQ@mail.gmail.com>
	<c14b49a2043adafbe9589fab7af4eceb6199726c.camel@cybertec.at>
	<CAFCRh-8DBZdfq_r+5jX9s8XPGxrANCOuWffkBBadpRTm7VP-OA@mail.gmail.com>
	<bee36d64-84e3-2918-9183-6035e1e6e221@aklaver.com>
	<CAFCRh-_wTu8mdxurTgjVO0Z19Xs1sam0ZFQqdXAJ5eF+7NLkpA@mail.gmail.com>
	<0730410A-9C79-4EE2-B21B-3502445A8700@thebuild.com>
	<CAFCRh-_cNHc0K0zLy6s0H7kaXOwPkC0mK74aXTGA2YOqKi89FA@mail.gmail.com>
	<1697225.1669924271@sss.pgh.pa.us>
	<CAFCRh--6qhmGKy5j7RVEBWW=r3YCeRm=WogwKxEA6Nhzcc0uDg@mail.gmail.com>
	<1258414512.930087.1669990257195@connect.xfinity.com>


> 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, against the output of pg_get_functiondef.

Assuming that changes to the tokenised code, when converted back to text, only involve renames of database objects, the result of 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 caused by 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 before and 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.






view thread (37+ messages)  latest in thread

Message-ID: <F472845F-DED3-4E7E-94DE-F4C65A1EECAA@gmail.com>
Permalink:  ../F472845F-DED3-4E7E-94DE-F4C65A1EECAA@gmail.com/
Also on:    postgresql.org/message-id/F472845F-DED3-4E7E-94DE-F4C65A1EECAA@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: haramrae@gmail.com, adaptron@comcast.net, ddevienne@gmail.com, tgl@sss.pgh.pa.us, xof@thebuild.com, adrian.klaver@aklaver.com, laurenz.albe@cybertec.at, david.g.johnston@gmail.com, m.tonies@upscene.com
  Subject: Re: Stored procedure code no longer stored in v14 and v15, changed behaviour
  In-Reply-To: <F472845F-DED3-4E7E-94DE-F4C65A1EECAA@gmail.com>
  References: <23DE96C56DFC404096553A22DDC5093B@MARTIJNWS> <CAKFQuwbYCk0oA3VT+ngEebBTBjdtGsVLEFOdPX2qqQJobA7rtg@mail.gmail.com> <1579912.1669908194@sss.pgh.pa.us> <CAFCRh--K2tahGetbJ_mtjiwvfFb9fF6SzjGnvbyoMKPr92FiTQ@mail.gmail.com> <c14b49a2043adafbe9589fab7af4eceb6199726c.camel@cybertec.at> <CAFCRh-8DBZdfq_r+5jX9s8XPGxrANCOuWffkBBadpRTm7VP-OA@mail.gmail.com> <bee36d64-84e3-2918-9183-6035e1e6e221@aklaver.com> <CAFCRh-_wTu8mdxurTgjVO0Z19Xs1sam0ZFQqdXAJ5eF+7NLkpA@mail.gmail.com> <0730410A-9C79-4EE2-B21B-3502445A8700@thebuild.com> <CAFCRh-_cNHc0K0zLy6s0H7kaXOwPkC0mK74aXTGA2YOqKi89FA@mail.gmail.com> <1697225.1669924271@sss.pgh.pa.us> <CAFCRh--6qhmGKy5j7RVEBWW=r3YCeRm=WogwKxEA6Nhzcc0uDg@mail.gmail.com> <1258414512.930087.1669990257195@connect.xfinity.com> <F472845F-DED3-4E7E-94DE-F4C65A1EECAA@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox