On enforcing default column value, AKA "Bloody nulls"

2025-01-16 Thread Wiwwo Staff
Hi all! In a scenario like this: > =# create table tab1(text1 text default 'from table'); > > =# create procedure ins_tab1(p_text1 text default 'from proc') language sql as > -# $$ > $# insert into tab1(text1) values (p_text1); > $# $$; > > =# call ins_tab1 (null); > > =# select * from tab1 ; >

Check psql parameter is passed, if not ask for it

2024-08-05 Thread Wiwwo Staff
Hi! I want to check if I pass the parameter "param1" to a sql script "delme.sql" like ``` \if ':param1' \echo :param1; \else \prompt 'Param1? ' :param1 \endif select :'param1'; ``` if parameter `param1` is not passed, the .sql should ask for it. If I run something like `psql -f delme.sql -v pa

Re: HISTIGNORE in psql

2024-06-18 Thread Wiwwo Staff
Hi Adrian, yes, of course, that is what I meant: being able to tell psql to exclude some patterns from being stored in the .psql_history file On Tue, 18 Jun 2024 at 16:12, Adrian Klaver wrote: > On 6/17/24 23:45, Wiwwo Staff wrote: > > Hi! > > As a big history lover, it would b

HISTIGNORE in psql

2024-06-17 Thread Wiwwo Staff
Hi! As a big history lover, it would be great to have the HISTIGNORE functionality added to psql. Have a great day! Wiwwo

Performance (and general) considerations between views and functions

2024-03-11 Thread Wiwwo Staff
Hi Community! I am in the process of re-writing SQLs in app code to a more DB side approach. My first idea was to write views, and let the app query those views; i'd need to rewrite some queries to expose the "parameters" (where condition fields) of those queries in the select part, to expose them

Re: FOR UPDATE SKIP LOCKED and get locked row/avoid updating other row(s)

2024-02-13 Thread Wiwwo Staff
On Tue, 13 Feb 2024 at 14:49, David G. Johnston wrote: > On Tuesday, February 13, 2024, Wiwwo Staff wrote: > >> Hi! >> I am implementing a queue using PostgreSQL. >> I am of course using "FOR UPDATE SKIP LOCKED". >> >> Is there any way I can t

FOR UPDATE SKIP LOCKED and get locked row/avoid updating other row(s)

2024-02-13 Thread Wiwwo Staff
Hi! I am implementing a queue using PostgreSQL. I am of course using "FOR UPDATE SKIP LOCKED". Is there any way I can tell PostgreSQL to only "operate" on the locked row, and/or a way to reference it? Some explanations of what I mean: - I have a table with N rows - I lock row X with a PG F

pg_rewind and replication user

2023-02-01 Thread Wiwwo Staff
Hi! Provided my replication user created with CREATE USER repl_user REPLICATION LOGIN ENCRYPTED PASSWORD''; If I run pg_rewing referring to this user postgres@host1:~: pg_rewind -D $PGDATA --source-server="host=nre_primary port=5432 user=repl_user passfile='/var/lib/postgresql/.pgpass' dbname=

Re: pg_rewind and user / passfile

2023-01-25 Thread Wiwwo Staff
Sorry for the confusion, I must have done some crazy stuff about the user of pg_basebackup. Please just consider the question: * is there a way to tell pg_rewind to use the passfile? Thanks! On Wed, Jan 25, 2023 at 10:37 AM Wiwwo Staff wrote: > Hi! > I have noticed, if I use > pg_b

pg_rewind and user / passfile

2023-01-25 Thread Wiwwo Staff
Hi! I have noticed, if I use pg_basebackup -D $PGDATA -h $NEW_PRIMARY -U $SOME_ADMIN_USER (where $SOME_ADMIN_USER is a privileged user, not the replica user) i got a "show primary_conninfo" as ; user= passfile='/var/lib/postgresql/.pgpass' channel_binding=prefer host=pg_red port=5432 sslmode=p

Re: Tablespace OID, database OID, relfilenode

2023-01-17 Thread Wiwwo Staff
a flame war here, just humbly proposing... Thanks all again! On Tue, Jan 17, 2023 at 4:44 PM Adrian Klaver wrote: > On 1/17/23 07:35, Wiwwo Staff wrote: > > Hi Laurenz, > > thanks for your answer! > > Ok, but I don't think "1663" is a sort of constant val

Re: Tablespace OID, database OID, relfilenode

2023-01-17 Thread Wiwwo Staff
nz Albe wrote: > On Tue, 2023-01-17 at 15:48 +0100, Wiwwo Staff wrote: > > Quick and to the point: > > > > If i execute > > select pg_relation_filepath('pgbench_accounts'); > > > > I get > > pg_relation_filepath > > ---

Tablespace OID, database OID, relfilenode

2023-01-17 Thread Wiwwo Staff
Hi! Quick and to the point: If i execute select pg_relation_filepath('pgbench_accounts'); I get pg_relation_filepath -- base/5/16398 where "base" is tablespace, but not tablespace OID, nor tablespace name. How do I link it to get from "base" the tablespace OID? Or, in othe

Disallow execution of shell commands from psql

2023-01-10 Thread Wiwwo Staff
Hi! Happy new (gregorian calendar) year! Somehow related to the proposal of having a `psql --idle` option, is there a way to disallow the command `\!` (and anything of the likes in psql? Sure, I can set the SHELL env var at run-time, but I still want to have postgres user to be a normal user, wit

Monitoring-only role

2022-12-06 Thread Wiwwo Staff
Hi there! Is there (a way to have) a "monitoring only" role in PG? This role should have access to stat views only,maybe something more, but no access to data whatsoever. Tnx!

Allow user to connect to replicas only

2022-08-04 Thread Wiwwo Staff
Hi! Is there any way to create a user allowed to connect to a/any read replica only, as in "not allowed to connect to primary"?

Feature request(?): Proxy User

2022-07-28 Thread Wiwwo Staff
Sorry to post solutions and links about alternative DBMSs, but I miss this sort of "sudo" ad database user level: https://oracle-base.com/articles/misc/proxy-users-and-connect-through Is there any approach to achieve the same result in Postgresql? Anyone sharing the need of this functionality? Tn

Re: Feature request: psql --idle

2022-07-28 Thread Wiwwo Staff
Thanks all for the alternative solutions. Yet, despite of my (wrong and misleading) use-case, I still share Julien's view of this being useful, whatever the parameter or the use-case. My 2 cents :-) On Wed, Jul 27, 2022 at 2:49 PM Wiwwo Staff wrote: > Since changing ph_hda.conf file

Feature request: psql --idle

2022-07-27 Thread Wiwwo Staff
Since changing ph_hda.conf file to give users access involves the restart of server, many companies I work(ed) use a bastion host, where users ssh to, and are allowed "somehow" use postgresql. Still, those users need some login shell. It would be great to give them psql as a login shell (in /etc/

show primary_conninfo unchanged after promotion?

2022-05-18 Thread Wiwwo Staff
Hi! i might be doing something wrong, but I cannot see what... Server is 14.3 (Debian 14.3-1.pgdg110+1) (at the time of writing, in Dockerfile FROM postgres:14) I have a 3 node cluster, starting with pg_red (172.26.0.2) as primary. I promote pg_green (172.26.0.4) as new primary, all other aligned

Re: On partitioning, PKs and FKs

2021-07-08 Thread Wiwwo Staff
On Thu, 8 Jul 2021 at 21:42, Alban Hertroys wrote: > On 2021-07-08 13:30, Ron wrote: > > Thus, the bigTable PK must be on id, columnX, (No, I don't like it > > either.) > > That's not entirely true. You can keep the PK on id if you additionally > create a unique constraint on (id, columnX). > Uh

Re: On partitioning, PKs and FKs

2021-07-08 Thread Wiwwo Staff
Big big variability on partitioned column, which is filtered (where condition) in (almost) all queries. On Thu, 8 Jul 2021 at 14:23, Michael Lewis wrote: > Why are you using hash partitioning? >

On partitioning, PKs and FKs

2021-07-08 Thread Wiwwo Staff
Hi! I have a big table bigTable which I partitioned by hash on field columnX, by creating bigTable_0, bigTable_1 etc. Since I need a PK on bigTable.id, and table is not partitioned by id, and columnX is not unique, i added PK on bigTable_0.id, bigTable_1.id etc. So far, so good. Now I have another