Re: Is this a bug ?

2019-10-23 Thread Gianni Ceccarelli
Weird, but apparently not a bug. From https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS > Two string constants that are only separated by whitespace with at > least one newline are concatenated and effectively treated as if the > string had been written as one co

Re: DBI && INSERT

2020-02-17 Thread Gianni Ceccarelli
On Mon, 17 Feb 2020 16:49:27 +0100 Matthias Apitz wrote: > I spend today some hours to nail down and insert problem into our > database with DBI like: > >my $rc = $my_dbh->do($my_sqlstatement); > > which returns 1 in $rc (which the following flow in our script took > as an error). The DBI d

Re: Catching errors with Perl DBI

2020-07-02 Thread Gianni Ceccarelli
On Thu, 2 Jul 2020 11:03:37 -0400 stan wrote: > my $sth = $dbh->prepare($stmt); > my $rv = $sth->execute() or die $DBI::errstr; that ``or die`` means: if the result of the ``execute`` is false (which only happens on error), throw an exception (which, as you noticed, terminates the process unless

Re: Syntax error when combining --set and --command has me stumped

2022-08-02 Thread Gianni Ceccarelli
If you can use bash, or set up some redirections from whatever you're using to execute ``psql``, you can do:: $ psql somedb --set num=42 <<<'select :num' Timing is on. Expanded display is used automatically. Line style is unicode. Border style is 2. ┌──┐ │ ?column? │ ├─

Re: Regular expression to UPPER() a lower case string

2022-12-10 Thread Gianni Ceccarelli
On 2022-12-10 Eagna wrote: > This should be very (very) easy - I don't know what I'm missing - > I've done quite complex regular expressions before and I don't know > what I'm doing wrong. Brain burping this morning! You're missing that: * `regexp_replace` doesn't work like that, at all * your l

Re: Regular expression to UPPER() a lower case string

2022-12-10 Thread Gianni Ceccarelli
On 2022-12-10 Eagna wrote: > If you have any ideas how it could be done indirectly/different > strategy - I'm all ears. You haven't explained what you're trying to accomplish. -- Dakkar - GPG public key fingerprint = A071 E618 DD2C 5901 9574

Re: Regular expression to UPPER() a lower case string

2022-12-10 Thread Gianni Ceccarelli
On 2022-12-10 "Peter J. Holzer" wrote: > > * your logic only works by accident for some languages (try to > > upcase a `ß` or a `ı`) > > This is also true of upper() and lower() and SQL does provide those. Well… > select upper('ı'); ┌───┐ │ upper │ ├───┤ │ I │ └───┘ (1 row) >

Re: Regular expression to UPPER() a lower case string

2022-12-10 Thread Gianni Ceccarelli
On 2022-12-10 Eagna wrote: > Hi again, and thanks for sticking with this. > > You haven't explained what you're trying to accomplish. > > Ok. > > CREATE TABLE test(x TEXT); > > INSERT INTO test VALUES ('abc'); > > SELECT REGEXP_REPLACE(x, '', '', 'g') > FROM test; > > Expected result: AB

Re: Regular expression to UPPER() a lower case string

2022-12-10 Thread Gianni Ceccarelli
On 2022-12-10 "Peter J. Holzer" wrote: > So, what's the point you are trying to make? I suspect I mis-understood a thing you wrote… ignore me. > > Of course all of this is dependent of locale, too. > Right. But why would that be different for regexp_replace than for > upper/lower? I was tryin

Re: Why does jsonb_set() remove non-mentioned keys?

2019-07-04 Thread Gianni Ceccarelli
Some experimentation: > \pset null '((null))' > select jsonb_set('{"foo":1}'::jsonb,'{bar}','null'::jsonb,true); ┌─┐ │jsonb_set│ ├─┤ │ {"bar": null, "foo": 1} │ └─┘ > select jsonb_set('{"foo":1}'::jsonb,'{ba

Re: Why does jsonb_set() remove non-mentioned keys?

2019-07-05 Thread Gianni Ceccarelli
Aha! I had mis-understood how "strict"-ness works. Thank you David for the explanation! Thomas: the two main pieces are these: > SQL null and json null are represented differently As far as SQL is concerned, `'null'::jsonb` is a valid (non-`NULL`) value. The SQL part of Postgres doesn't "look i

Re: Reset Postgresql users password

2023-07-12 Thread Gianni Ceccarelli
On 2023-07-12 Johnathan Tiamoh wrote: > I wish to find out if there is a way to reset all users in Postgresql > password to the same password at once. I guess you could update the `pg_catalog.pg_authid` table, see https://www.postgresql.org/docs/15/catalog-pg-authid.html -- Dakkar -

Re: pass non-formated query to PL function

2021-04-02 Thread Gianni Ceccarelli
On 2021-04-02 Joao Miguel Ferreira wrote: > Is it possible, in PL/pgSQL, to pass an argument to a function which > is actually a "query skeleton" that the method will "fill in the > blanks" and execute it or return it to the caller after ? you probably want to use the ``EXECUTE`` command: https:/

Re: unicode match normal forms

2021-05-17 Thread Gianni Ceccarelli
On 17 May 2021 13:27:40 - haman...@t-online.de wrote: > in unicode letter ä exists in two versions - linux and windows use a > composite whereas macos prefers the decomposed form. Is there any way > to make a semi-exact match that accepts both variants? You should probably normalise the string

Re: unicode match normal forms

2021-05-17 Thread Gianni Ceccarelli
On 17 May 2021 13:27:40 - haman...@t-online.de wrote: > in unicode letter ä exists in two versions - linux and windows use a > composite whereas macos prefers the decomposed form. Is there any > way to make a semi-exact match that accepts both variants? Actually, re-reading your request, you w

Re: unicode match normal forms

2021-05-17 Thread Gianni Ceccarelli
On Mon, 17 May 2021 15:45:00 +0200 Matthias Apitz wrote: > There is only *one* codepoint for the German letter a Umlaut: > LATIN SMALL LETTER A WITH DIAERESI U+00E4 True. On the other hand, the sequence: * U+0061 LATIN SMALL LETTER A * U+0308 COMBINING DIAERESIS will render exactly the same gly

Re: case insensitive collation of Greek's sigma

2021-12-02 Thread Gianni Ceccarelli
I realise this may not be applicable to the original problem, but non-deterministic collations seems to offer a solution:: dakkar@[local] dakkar=> create collation "en-US-ins-icu" ( provider=icu, locale='en-US-u-ks-level2', deterministic=false ); dakkar@[l

Re: Timezone: resolve $TZDIR in runtime

2024-10-21 Thread Gianni Ceccarelli
On 2024-10-21 Anatolii Smolianinov wrote: > date(1) does not set timezone dir: but it uses TZ, and, in man, it > refers to tzselect: > > use tzselect to find TZ" That's an imperative "use", not an indicative. In other words: the user, to find an appropriate value for `TZ`, should run the command

Re: Functions and Indexes

2024-11-18 Thread Gianni Ceccarelli
On Mon, 18 Nov 2024 15:37:57 +0100 Moreno Andreo wrote: > If a column appears in the WHERE clause (and so it should be placed > in index), in case it is "processed" in a function (see below), is it > possible to insert this function to further narrow down things? You probably want to look at ht

Version upgrades and replication

2024-11-23 Thread Gianni Ceccarelli
Hello all! I have a primary+replica PostgreSQL that I think work fine. I created the replica's data directory using:: pg_basebackup -D $datadir -h $primary_host -U $replicauser \ --write-recovery-conf \ --create-slot --slot=$slotname after creating the u