Re: easy way of copying regex_t - Mailing list pgsql-hackers

From Tom Lane
Subject Re: easy way of copying regex_t
Date
Msg-id 21779.1453671690@sss.pgh.pa.us
Whole thread Raw
In response to Re: easy way of copying regex_t  (Artur Zakirov <a.zakirov@postgrespro.ru>)
Responses Re: easy way of copying regex_t  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-hackers
Artur Zakirov <a.zakirov@postgrespro.ru> writes:
> With this message I want to send some patch to your repository with 
> draft of a code, which allows shared_ispell to copy regex_t.

Allowing ispell.c to know that much about regex internals strikes me as
completely unacceptable from a modularity or maintainability standpoint.
If we want to do that, the appropriate thing would be to add a function
to backend/regex/ that copies a regex_t.

However, I'm rather suspicious of the safety of copying a regex_t into
shared memory in the first place.  It contains function pointers, which
we have not historically assumed would be portable between different
backend processes.  And the regex library is old enough to have never
heard of thread safety, so I'm not really sure that it considers the
regex_t structures to be read-only at execution time.

> shared_ispell loads dictionaries into a shared memory. The main benefits 
> are:
> - saving of memory. Every dictionary is loaded only once. Dictionaries 
> are not loaded for each backend. In current version of PostgreSQL 
> dictionaires are loaded for each backend where it was requested.
> - saving of time. The first load of a dictionary takes much time. With 
> this patch dictionaries will be loaded only once.

Where does the shared memory space come from?  It would not take too
many dictionaries to use up whatever slop is available.
        regards, tom lane



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Removing Functionally Dependent GROUP BY Columns
Next
From: "Dickson S. Guedes"
Date:
Subject: Re: Why format() adds double quote?