From: Konrad Witaszczyk <def@FreeBSD.org>
To: Achilleas Mantzios <achill@matrix.gatewaynet.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Recreating functions after starting the database server.
Date: Wed, 31 Jan 2018 14:39:54 +0100
Message-ID: <55917059-846c-8d33-8732-2e1a434d3846@FreeBSD.org> (raw)
In-Reply-To: <fb50c957-b840-55a3-f5f5-e1519d049ad1@matrix.gatewaynet.com>
References: <62735ca9-2245-8a56-acd5-20f7871244d8@FreeBSD.org>
<d89873df-3d8b-7444-daf7-10eb7ab6d89f@matrix.gatewaynet.com>
<a9a0111e-ae07-4582-58bf-3a0227c9209d@FreeBSD.org>
<fb50c957-b840-55a3-f5f5-e1519d049ad1@matrix.gatewaynet.com>
On 01/31/2018 14:32, Achilleas Mantzios wrote:
> On 31/01/2018 15:22, Konrad Witaszczyk wrote:
>> On 01/31/2018 14:03, Achilleas Mantzios wrote:
>>> On 31/01/2018 14:45, Konrad Witaszczyk wrote:
>>>> Hi,
>>>>
>>>> I'm considering changing my database schema upgrade routines to recreate
>>>> functions and all objects depending on them (e.g. triggers, views) just after
>>>> the database server is started. It would make the routines much simpler since
>>>> they wouldn't have to depend on the history of the schema.
>>>>
>>>> Does anyone has any experience with recreating all functions and triggers to
>>>> upgrade a database schema assuming that during the upgrade there are no client
>>>> connections to the database?
>>>>
>>>> Does anyone see any problems with such approach in terms of consistency and
>>>> performance? I'm not familiar with PostgreSQL internals and I'm not sure
>>>> how it
>>>> would affect the planner when using various function volatile categories.
>>> Do you have indexes that use those functions?
>> There are no indexes which use functions. I can see it would be a problem in the
>> other case since indexes would have to be rebuilt. Thanks for pointing it out.
>>
>>> It would help to just give an example of your situation and what you are trying
>>> to solve.
>> In my case the upgrade routines run migration scripts which modify a database
>> schema. Besides that I have a bunch of SQL files with the schema that can be
>> used to initialize a new database.
>>
>>> Why recreate triggers, indexes and functions after server startup instead of
>>> leaving them?
>>> Why create needless traffic?
>> I would like to eliminate the migration scripts to have all definitions in one
>> file which would be easier to maintain. I'm mainly interested in functions and
>> hence objects depending on them. However I wouldn't like to recreate indexes as
>> it's not needed.
> If it is only functions which retain their signature and only change the code,
> there is no need to touch their related objects. You can CREATE OR REPLACE
> those functions and change nothing else.
I know that it works as long as a function doesn't change its return type. I'd
like to cover this case as well not to worry about it in the future. Hence I'm
looking for a general method with the above assumptions.
Attachments:
signature.asc (application/pgp-signature, 962B) download
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: def@FreeBSD.org, achill@matrix.gatewaynet.com
Subject: Re: Recreating functions after starting the database server.
In-Reply-To: <55917059-846c-8d33-8732-2e1a434d3846@FreeBSD.org>
References: <62735ca9-2245-8a56-acd5-20f7871244d8@FreeBSD.org> <d89873df-3d8b-7444-daf7-10eb7ab6d89f@matrix.gatewaynet.com> <a9a0111e-ae07-4582-58bf-3a0227c9209d@FreeBSD.org> <fb50c957-b840-55a3-f5f5-e1519d049ad1@matrix.gatewaynet.com> <55917059-846c-8d33-8732-2e1a434d3846@FreeBSD.org>
* 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