Re: pgbouncer best practices

2023-07-10 Thread Gurjeet Singh
On Sun, Jul 9, 2023 at 6:28 AM Rita wrote: > > Is there a way to see how many queued connections there are? Looking at the > stats I can't seem to figure that out. pgbouncer exposes quite a few statistics via the SHOW commands [1]. See if any of those help. [1]: https://www.pgbouncer.org/usage.

Re: Need Help On Upgrade

2023-07-10 Thread Laurenz Albe
On Mon, 2023-07-10 at 20:38 -0400, Johnathan Tiamoh wrote: > Below is the full error message. > > 2023-06-27 05:01:27.385 CDT| XXX (60930)| > APPNAME=[unknown]| DB=postgres| USER=grafana| PID=9061| 1| authentication| > PGE-28P01: FATAL:  password authentication failed for use

Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"

2023-07-10 Thread David G. Johnston
On Mon, Jul 10, 2023 at 6:28 PM Tom Lane wrote: > Kyotaro Horiguchi writes: > > Even given this, premising users keeping the volatility marks in line > > with the actual behavior of their corresponding functions, it might be > > benetifical to prohibit changes to the volatility category while it

Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"

2023-07-10 Thread Kyotaro Horiguchi
At Tue, 11 Jul 2023 10:14:29 +0900 (JST), Kyotaro Horiguchi wrote in > At Sun, 9 Jul 2023 14:22:37 +, Avi Weinberg wrote in > > Hi, > > > > If you attempt to create an index based on function that is not IMMUTABLE > > you will get an exception "ERROR: functions in index predicate must b

Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"

2023-07-10 Thread Tom Lane
Kyotaro Horiguchi writes: > Even given this, premising users keeping the volatility marks in line > with the actual behavior of their corresponding functions, it might be > benetifical to prohibit changes to the volatility category while it's > being used for indices. Are you going to prohibit ch

Re: Is anyone using db_user_namespace?

2023-07-10 Thread Ian Lawrence Barwick
2023年7月11日(火) 2:45 Nathan Bossart : > > On Fri, Jun 30, 2023 at 02:56:08PM -0700, Nathan Bossart wrote: > > Over in pgsql-hackers, I've proposed removing the db_user_namespace > > parameter in v17 [0]. I am personally not aware of anyone using this > > parameter, but I wanted to give folks an oppo

Re: Problematic enforcement of "ERROR: functions in index predicate must be marked IMMUTABLE"

2023-07-10 Thread Kyotaro Horiguchi
At Sun, 9 Jul 2023 14:22:37 +, Avi Weinberg wrote in > Hi, > > If you attempt to create an index based on function that is not IMMUTABLE you > will get an exception "ERROR: functions in index predicate must be marked > IMMUTABLE". However, if you created the index when the function was

Re: Need Help On Upgrade

2023-07-10 Thread Johnathan Tiamoh
Sorry Adrian, Below is the full error message. 2023-06-27 05:01:27.385 CDT| XXX (60930)| APPNAME=[unknown]| DB=postgres| USER=grafana| PID=9061| 1| authentication| PGE-28P01: FATAL: password authentication failed for user "grafana" 2023-06-27 05:01:27.385 CDT| XXX

Re: Need Help On Upgrade

2023-07-10 Thread Adrian Klaver
On 7/10/23 13:20, Johnathan Tiamoh wrote: Ok Adrian, Postgres 9.5       postgresql.conf          password_encryption  = ?  md5  > wish is the default for 9.5       pg_hba.conf    -> md5           Provide the relevant lines Postgres 14.8       postgresql.conf        

Re: Using "exit" to bring "goto" functionality.

2023-07-10 Thread Bryn Llewellyn
> pavel.steh...@gmail.com wrote: > >> b...@yugabyte.com wrote: >> >> As it happens, Oracle's PL/SQL has a "goto" statement. But PL/pgSQL does >> not. (I assume that this is because "goto" is considered a bad thing.) But >> PL/SQL programmers do use it. However, the doc section: > > The reason

Re: Using "exit" to bring "goto" functionality.

2023-07-10 Thread Pavel Stehule
Hi > As it happens, Oracle's PL/SQL has a "goto" statement. But PL/pgSQL does > not. (I assume that this is because "goto" is considered a bad thing.) But > PL/SQL programmers do use it. However, the doc section: > The reason why PL/pgSQL has not "goto" statement is mainly technological. PL/pgSQ

Re: Using "exit" to bring "goto" functionality.

2023-07-10 Thread Bryn Llewellyn
> x...@thebuild.com wrote: > >> b...@yugabyte.com wrote: >> >> What is the rationale for supporting what seems to be on its face this >> strange functionality? > > It allows you to EXIT or CONTINUE a loop that is not the innermost one, by > naming the label of an outer loop. One can debate end

Re: Need Help On Upgrade

2023-07-10 Thread Johnathan Tiamoh
> Ok Adrian, > > Postgres 9.5 > > postgresql.conf > > password_encryption = ? md5 > wish is the default for 9.5 > > pg_hba.conf-> md5 > > Provide the relevant lines > > Postgres 14.8 > > postgresql.conf > > password_encryption = ?

Re: Need Help On Upgrade

2023-07-10 Thread Johnathan Tiamoh
Ok Adrian, Postgres 9.5 postgresql.conf password_encryption = ? md5 > wish is the default for 9.5 pg_hba.conf-> md5 Provide the relevant lines Postgres 14.8 postgresql.conf password_encryption = ? scram-sha-256 > wish is t

Re: Need Help On Upgrade

2023-07-10 Thread Adrian Klaver
On 7/10/23 12:55, Johnathan Tiamoh wrote: Please reply to list also. Ccing list Ok Adrian, Postgres 9.5     postgresql.conf        password_encryption  = ?  md5  > wish is the default for 9.5     pg_hba.conf    -> md5         Provide the relevant lines Postgres 14.

Re: Need Help On Upgrade

2023-07-10 Thread Adrian Klaver
On 7/10/23 11:15, Johnathan Tiamoh wrote: Hello, I upgraded from postgresql 9.5 to 14.8. After the upgrade users were not able to connect due to password hash. The password encryption was on scram-sha-256. The password hash was on md5. in the pg_hba.conf file the authentication method was md

Re: Using "exit" to bring "goto" functionality.

2023-07-10 Thread Adrian Klaver
On 7/10/23 12:08, DAVID ROTH wrote: I am a newbe at my current job. They have a separate log table for every table because they want all the columns. I have been looking for a way to go to a common log table without requiring major changes to the application. With your help, I have a proof of

Re: Using "exit" to bring "goto" functionality.

2023-07-10 Thread DAVID ROTH
I am a newbe at my current job. They have a separate log table for every table because they want all the columns. I have been looking for a way to go to a common log table without requiring major changes to the application. With your help, I have a proof of principle that I can demonstrate now.

Re: Using "exit" to bring "goto" functionality.

2023-07-10 Thread Christophe Pettus
> On Jul 10, 2023, at 11:54, Bryn Llewellyn wrote: > > What is the rationale for supporting what seems to be on its face this > strange functionality? It allows you to EXIT or CONTINUE a loop that is not the innermost one, by naming the label of an outer loop. One can debate endlessly whet

Using "exit" to bring "goto" functionality.

2023-07-10 Thread Bryn Llewellyn
I wanted to see what error(s) would be reported if "exit" or "continue" is used, in PL/pgSQL, outside of a loop—and in particular if these were reported as syntax errors or runtime errors. There were no surprises with "continue". But I was surprised by this: create procedure p() language plpg

Re: Trigger Function question

2023-07-10 Thread Christophe Pettus
> On Jul 10, 2023, at 11:46, DAVID ROTH wrote: > > Is there a way to get new.* into a jsonb column? The to_jsonb() function accepts a row type like NEW.*, and returns a JSONB object with the keys as column names.

Re: Trigger Function question

2023-07-10 Thread Marcos Pegoraro
> > Is there a way to get new.* into a jsonb column? > select json_object_agg(js.key, js.value) from json_each_text(row_to_json(new.*)) js Marcos

Re: Trigger Function question

2023-07-10 Thread DAVID ROTH
I saw your message about a "few" columns and missed the new.* notation. Is there a way to get new.* into a jsonb column? > On 07/10/2023 2:38 PM EDT Christophe Pettus wrote: > > > > On Jul 10, 2023, at 11:37, DAVID ROTH wrote: > > > > Thanks for the example. I have a test trigger now that do

Re: Trigger Function question

2023-07-10 Thread DAVID ROTH
I was hoping that NEW could be treated as a record or as an arrayy similar to pg_argv. > On 07/10/2023 2:31 PM EDT Christophe Pettus wrote: > > > > On Jul 10, 2023, at 11:29, DAVID ROTH wrote: > > > > I want to use a single trigger function to log multiple tables and the > > tables have di

Re: Trigger Function question

2023-07-10 Thread Christophe Pettus
> On Jul 10, 2023, at 11:37, DAVID ROTH wrote: > > Thanks for the example. I have a test trigger now that does that but my > application needs all of the columns. I'm not quite sure I understanding. Logging NEW.* and OLD.* *does* get all the columns, without having to specific query to fin

Re: Trigger Function question

2023-07-10 Thread DAVID ROTH
Thanks for the example. I have a test trigger now that does that but my application needs all of the columns. > On 07/10/2023 2:31 PM EDT Christophe Pettus wrote: > > > > On Jul 10, 2023, at 11:29, DAVID ROTH wrote: > > > > I want to use a single trigger function to log multiple tables and

Re: Trigger Function question

2023-07-10 Thread Christophe Pettus
> On Jul 10, 2023, at 11:29, DAVID ROTH wrote: > > I want to use a single trigger function to log multiple tables and the tables > have different columns. I can get the names of the columns from the catalog. > But I have not been able to figure out how to get NEW.x when x is not known > u

Re: Trigger Function question

2023-07-10 Thread DAVID ROTH
I want to use a single trigger function to log multiple tables and the tables have different columns. I can get the names of the columns from the catalog. But I have not been able to figure out how to get NEW.x when x is not known until run time. > On 07/10/2023 2:23 PM EDT Christophe Pettus

Re: Trigger Function question

2023-07-10 Thread Christophe Pettus
> On Jul 10, 2023, at 11:20, DAVID ROTH wrote: > > In a trigger function, is there a way to get a list of all of the columns in > the triggering table? You can get the table that the trigger fired on with TG_TABLE_SCHEMA and TG_TABLE_NAME, and then query the system catalogs to get a list of

Trigger Function question

2023-07-10 Thread DAVID ROTH
In a trigger function, is there a way to get a list of all of the columns in the triggering table? I want to be able to use a single trigger function with multiple tables. Thanks

Need Help On Upgrade

2023-07-10 Thread Johnathan Tiamoh
Hello, I upgraded from postgresql 9.5 to 14.8. After the upgrade users were not able to connect due to password hash. The password encryption was on scram-sha-256. The password hash was on md5. in the pg_hba.conf file the authentication method was md5. I do not know why users could not connect be

Re: Is anyone using db_user_namespace?

2023-07-10 Thread Nathan Bossart
On Fri, Jun 30, 2023 at 02:56:08PM -0700, Nathan Bossart wrote: > Over in pgsql-hackers, I've proposed removing the db_user_namespace > parameter in v17 [0]. I am personally not aware of anyone using this > parameter, but I wanted to give folks an opportunity to object in case they > are using it

Re: what causes new temp schemas to be created

2023-07-10 Thread Tom Lane
Ted Toth writes: > So it's an optimization to reuse existing but currently unused temp > schemas, correct? Exactly. We could just destroy and recreate the old temp schema, but that seems to lead to useless catalog churn. Instead we just destroy any old contents, if there's an existing temp sche

Re: what causes new temp schemas to be created

2023-07-10 Thread Ted Toth
So it's an optimization to reuse existing but currently unused temp schemas, correct? On Mon, Jul 10, 2023 at 11:22 AM David G. Johnston wrote: > > On Mon, Jul 10, 2023 at 9:20 AM Ted Toth wrote: >> >> I don't see that the schema is removed when the session is over and I >> see other sessions co

Re: what causes new temp schemas to be created

2023-07-10 Thread David G. Johnston
On Mon, Jul 10, 2023 at 9:20 AM Ted Toth wrote: > I don't see that the schema is removed when the session is over and I > see other sessions come along later and use it. I'm assuming here that > a session is started on connect and ended when the connection is > closed. > > The first time a sessio

Re: what causes new temp schemas to be created

2023-07-10 Thread Ted Toth
I don't see that the schema is removed when the session is over and I see other sessions come along later and use it. I'm assuming here that a session is started on connect and ended when the connection is closed. On Mon, Jul 10, 2023 at 9:21 AM David G. Johnston wrote: > > On Mon, Jul 10, 2023 a

Prevent LSN pointer advancement in case of cursor exception (wal2json + pg_logical_slot_get_changes)

2023-07-10 Thread Mertez
Hi, we would like to fetch changes from the wal using a combination of the cursor and the sql function pg_logical_slot_get_changes that also takes care about the position of the LSN pointer. The decision to use a cursor in the Python script was to mitigate the out-of-memory exceptions in case of

Re: Moving data from huge table slow, min() query on indexed column taking 38s

2023-07-10 Thread Dimitrios Apostolou
Thanks! I have completed the transfer by taking down the database and working exclusively on it, but I still wonder how one could do it in production without exclusive locks. The loop with small DELETE...INSERT transactions I posted on the parent post bloats the table fast. The link you posted co

Re: what causes new temp schemas to be created

2023-07-10 Thread Ron
On 7/10/23 09:20, David G. Johnston wrote: On Mon, Jul 10, 2023 at 7:18 AM Ted Toth wrote: When a temp table is created I see a pg_temp_NNN (for example pg_temp_3, pg_toast_temp_3) schemas created when/why are additional temp schemas created( pg_temp_4/pg_toast_temp_4)? Temporary

Re: what causes new temp schemas to be created

2023-07-10 Thread David G. Johnston
On Mon, Jul 10, 2023 at 7:18 AM Ted Toth wrote: > When a temp table is created I see a pg_temp_NNN (for example > pg_temp_3, pg_toast_temp_3) schemas created when/why are additional > temp schemas created( pg_temp_4/pg_toast_temp_4)? > > Temporary schemas are isolated to the session they are crea

what causes new temp schemas to be created

2023-07-10 Thread Ted Toth
When a temp table is created I see a pg_temp_NNN (for example pg_temp_3, pg_toast_temp_3) schemas created when/why are additional temp schemas created( pg_temp_4/pg_toast_temp_4)? Ted

Re: search_path for replica-mode

2023-07-10 Thread David G. Johnston
On Monday, July 10, 2023, André Kutepow wrote: > There is a trigger in the database > > SET search_path TO "$user", public; > > CREATE OR REPLACE FUNCTION art__a_iu_func() > BEGIN > INSERT INTO table_z... --*»table_z« is in schema public* > END; > > CREATE OR REPLACE TRIGGER art__a_iu > A

search_path for replica-mode

2023-07-10 Thread André Kutepow
There is a trigger in the database SET search_path TO "$user", public; CREATE OR REPLACE FUNCTION art__a_iu_func() BEGIN   INSERT INTO table_z...   --//»table_z« is in schema public// END; CREATE OR REPLACE TRIGGER art__a_iu     AFTER INSERT OR UPDATE OF ak_nr     ON

search_path for replica-mode

2023-07-10 Thread André Kutepow
There is a trigger in the database SET search_path TO "$user", public; CREATE OR REPLACE FUNCTION art__a_iu_func() BEGIN   INSERT INTO table_z...   --//»table_z« is in schema public// END; CREATE OR REPLACE TRIGGER art__a_iu     AFTER INSERT OR UPDATE OF ak_nr     ON

Re: Query regarding managing Replication

2023-07-10 Thread Julien Rouhaud
On Mon, Jul 10, 2023 at 3:41 PM Ashok Patil wrote: > Hello Julien, > > I need some more help regarding replication. > > Where Primary server can switch to Standby server role and stand by server > can switch to Primary server role. > [image: image.png] > In our case we maintain two servers Server

Re: INSERT UNIQUE row?

2023-07-10 Thread Erik Wienhold
> On 10/07/2023 04:25 CEST p...@pfortin.com wrote: > > On Sun, 9 Jul 2023 17:04:03 -0700 Adrian Klaver wrote: > > >On 7/9/23 15:58, p...@pfortin.com wrote: > >> Hi, > >> > >> Trying to figure out how to insert new property addresses into an > >> existing table. > >> > >> Can a UNIQUE constraint be

Re: Query regarding managing Replication

2023-07-10 Thread Ashok Patil
Hello Julien, I need some more help regarding replication. Where Primary server can switch to Standby server role and stand by server can switch to Primary server role. [image: image.png] In our case we maintain two servers Server1 and Server2.. Server1 will be active and Server2 will be passive.