-Original Message-
From: Alvaro Herrera
Sent: Tuesday, March 2, 2021 2:19 PM
To: Alexander Farber
Cc: pgsql-general
Subject: Re: Localizing stored functions by replacing placeholders in their body
On 2021-Mar-02, Alexander Farber wrote:
> CREATE OR REPLACE FUNCTION localize_hello()
>
I'm trying to follow instrux in V12:18.9.5 Creating Certificates. [1]
I'm stuck in my basement so all references to "/CN=FQN" have been set to
$(hostname), just the hostname, because $(domainname) returns "(none)"
which I presume is akin to null.
With my newly minted certs and keys using psql
On 2021-Mar-02, Asaf Flescher wrote:
> I'm not sure if this is a bug or I'm missing something regarding how
> partitioning is supposed to work but I've noticed (in Postgres 12.6) that
> if I have a partitioned table, and then try to add a partition to it via
> CREATE TABLE ... PARTITION OF, the st
Hi,
I'm not sure if this is a bug or I'm missing something regarding how
partitioning is supposed to work but I've noticed (in Postgres 12.6) that
if I have a partitioned table, and then try to add a partition to it via
CREATE TABLE ... PARTITION OF, the statement will grab an AccessExclusive
lock
> I'm not sure this is a great approach to in-database translations: you
> have one function per string, which is cumbersome, bloated and probably
> slow. I would suggest having a function that takes a string and returns
> its translation, which is obtained from a couple of tables: one where
> the
On 2021-Mar-02, Alexander Farber wrote:
> CREATE OR REPLACE FUNCTION localize_hello()
> RETURNS text AS
> $func$
> SELECT '$(hello)';
> $func$ LANGUAGE sql IMMUTABLE;
I'm not sure this is a great approach to in-database translations: you
have one function per string, which is cumb
I think I will try this approach:
\set localized_declaration `sed 's/this/that/' my_func.sql`
:localized_declaration
Thank you for your input
Ah, I understand, that was the wrong EXECUTE, thank you.
Another idea: can't I use \set command for my purpose of localizing stored
functions?
\set my_func_declaration `sed 's/this/that/' my_func.sql`
But how to execute the declaration? I can only echo it with
select (:'my_func_declaration');
út 2. 3. 2021 v 17:55 odesílatel Alexander Farber <
alexander.far...@gmail.com> napsal:
> Thank you for the \! hint, Pavel, didn't know about that!
>
> Is it possible to have a pure SQL solution? (To avoid having to install
> "sed" on my Win 10 PC)
>
You should to use PLpgSQL EXECUTE statement, n
Thank you for the \! hint, Pavel, didn't know about that!
Is it possible to have a pure SQL solution? (To avoid having to install
"sed" on my Win 10 PC)
Maybe by using EXECUTE?
EXECUTE REGEXP_REPLACE(
$localize$
CREATE OR REPLACE FUNCTION my_func()
RETURNS text AS
$func$
SELECT
út 2. 3. 2021 v 17:18 odesílatel Alexander Farber <
alexander.far...@gmail.com> napsal:
> Or is it possible to call external commands from an sql script, like
>
> \i "sed 's/this/that/' some.sql"
>
you can use \! statement for execution of external statements
Pavel
Or is it possible to call external commands from an sql script, like
\i "sed 's/this/that/' some.sql"
Yes, good point about the '\$', thank you Tom.
The reason I am trying not to use sed, is because I deploy my database by
executing a single command:
psql words_en < words_en.sql
And the file words_en.sql has the contents:
\i words_hash.sql
\i words_all_letters.sql
\i words_get_hint.sql
\i words
Alexander Farber writes:
> update pg_proc set prosrc = regexp_replace(prosrc, '$\(\w+\)','Hi
> english','g') where proname='localize_hello';
"$" is a metacharacter in regexes ... writing \$ might help.
(The idea of direct updates on the system catalogs seems like a really
bad one. Why not pass
Hello,
I have an app using PostgreSQL 13.2, in 6 different human languages (each
using different database, but same source code).
Currently to localize strings return/set by the stored functions I either
get localized strings from a table or maintain stored function source code
in 6 different lan
On Tue, 2021-03-02 at 14:16 +0530, Brajendra Pratap Singh wrote:
> unable to connect to 'dbname='postgres' port=5432': could not connect to
> server: No such file or directory
> Is the server running locally and
> accepting
>
Hi Kristjan,
Thank you for this information.
"postgres the memory is slowly eaten away when doing updates within plsql
loop" for this memory issue, I want to check if it exists in our current
postgresql version. And let developer change to use python for loop also
need to show them the proof, how
Hi Michael,
Thank you, after create index to the temp table column, time cost become
smaller
Michael Lewis 于2021年3月2日周二 上午12:08写道:
> 1) Don't pretend it is a left join when your where clause will turn it
> into an INNER join.
> LEFT JOIN pol gp ON gab.policy_id = gp.id
> WHERE
>
> *
On Tue, 2 Mar 2021 at 21:53, Brajendra Pratap Singh
wrote:
> We are getting the below issue while executing the backup through pgbackrest.
> 2021-03-02 02:10:01.622 P00 ERROR: [056]: unable to find primary cluster -
> cannot proceed
That's not an error that's coming from PostgreSQL.
You might
Hi Yi,
I found that in postgres the memory is slowly eaten away when doing
updates within plsql loop. It only gets released once the whole block
completes. While it is ok for small tables you will eventually run out
of memory for really big ones. The working approach was to do the loop
in e.g a py
Hi ,
We are getting the below issue while executing the backup through
pgbackrest.
2021-03-02 02:10:01.620 P00 INFO: backup command begin 2.28:
--archive-check --archive-copy --compress --db-timeout=7200
--log-level-console=detail --log-level-file=detail
--log-level-stderr=detail --log-path=/ap
21 matches
Mail list logo