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

2019-07-04 Thread David G. Johnston
On Thu, Jul 4, 2019 at 2:09 PM David G. Johnston wrote: > On Thursday, July 4, 2019, Gianni Ceccarelli > wrote: > >> >> > select to_jsonb('null'::text); >> ┌──┐ >> │ to_jsonb │ >> ├──┤ >> │ "null" │ >> └──┘ >> >> > Json null > > Sorry, my bad on this last one. You cann

Re: Converting to identity columns with domains on PK columns

2019-07-04 Thread Adrian Klaver
On 7/4/19 1:27 PM, Adrian Klaver wrote: On 7/4/19 1:03 PM, PegoraroF10 wrote: ok, thanks for the explanation but ... I cannot add a field and move data, constraints, triggers, identity to it because my pk field will be repositioned to the last field on that table and I have lots of other codes

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

2019-07-04 Thread David G. Johnston
On Thursday, July 4, 2019, Gianni Ceccarelli wrote: > Some experimentation: > > > \pset null '((null))' > > > select jsonb_set('{"foo":1}'::jsonb,'{bar}','null'::jsonb,true); > ┌─┐ > │jsonb_set│ > ├─┤ > │ {"bar": null, "foo": 1} │ >

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: Converting to identity columns with domains on PK columns

2019-07-04 Thread Adrian Klaver
On 7/4/19 1:27 PM, Adrian Klaver wrote: On 7/4/19 1:03 PM, PegoraroF10 wrote: ok, thanks for the explanation but ... I cannot add a field and move data, constraints, triggers, identity to it because my pk field will be repositioned to the last field on that table and I have lots of other codes

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

2019-07-04 Thread Thomas Kellerer
David G. Johnston schrieb am 04.07.2019 um 18:20: On Thu, Jul 4, 2019 at 6:18 AM Thomas Kellerer mailto:spam_ea...@gmx.net>> wrote: Why does    select jsonb_set('{"foo": 1}'::jsonb, '{bar}', to_jsonb(null::int), true) return NULL when all it should do is to add a second key? Bo

Re: Converting to identity columns with domains on PK columns

2019-07-04 Thread Adrian Klaver
On 7/4/19 1:03 PM, PegoraroF10 wrote: ok, thanks for the explanation but ... I cannot add a field and move data, constraints, triggers, identity to it because my pk field will be repositioned to the last field on that table and I have lots of other codes which point to pk as the first field on ev

Re: Converting to identity columns with domains on PK columns

2019-07-04 Thread PegoraroF10
ok, thanks for the explanation but ... I cannot add a field and move data, constraints, triggers, identity to it because my pk field will be repositioned to the last field on that table and I have lots of other codes which point to pk as the first field on every table. So, there is a way to conver

Re: Converting to identity columns with domains on PK columns

2019-07-04 Thread Adrian Klaver
On 7/4/19 12:41 PM, PegoraroF10 wrote: Domains on Postgres are really strange to me. Am I creating a domain which is exactly equal to integer, right ? create domain i32 as integer; create domain T50 as varchar(50); Create table MyTable( ID I32 not null primary key, Description T50); Then, afte

Converting to identity columns with domains on PK columns

2019-07-04 Thread PegoraroF10
Domains on Postgres are really strange to me. Am I creating a domain which is exactly equal to integer, right ? create domain i32 as integer; create domain T50 as varchar(50); Create table MyTable( ID I32 not null primary key, Description T50); Then, after inserts and updates done to that table,

Re: PostgreSQL upgrade from 9.4.2 to 9.6.12

2019-07-04 Thread Jonathan Harden
If you're doing this in RDS make sure to check what extensions each of your databases in your RDS instance has (we use PostGIS and hstore for example) and upgrade them incrementally. AWS provide the right libs installed to do those updates between each engine version, but not necessarily between en

Re: pg_dump (COPY) hanging intermittently

2019-07-04 Thread Ben Snaidero
On Thu, Jun 27, 2019 at 3:19 PM Tom Lane wrote: > Ben Snaidero writes: > > Do these stack traces shed help at all? > > None worth mentioning :-(. Can you rebuild with debug symbols? > > regards, tom lane > So I've rebuilt with debug symbols and for some reason I am now

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

2019-07-04 Thread David G. Johnston
On Thu, Jul 4, 2019 at 6:18 AM Thomas Kellerer wrote: > Why does > >select jsonb_set('{"foo": 1}'::jsonb, '{bar}', to_jsonb(null::int), > true) > > return NULL when all it should do is to add a second key? > Both functions involved are defined as being STRICT (null on null input). You need t

Re: PostgreSQL upgrade from 9.4.2 to 9.6.12

2019-07-04 Thread Adrian Klaver
On 7/4/19 7:48 AM, Ashwini Singh wrote: Hi Everyone, We have a legacy application running on Ruby on Rails on AWS infrastructure. We wanted to do a DB upgrade from PostgreSQL version 9.4.2 to 9.6.12. We tried finding out any breaking changes from 9.4.x to 9.6.x upgrade but could not find ou

PostgreSQL upgrade from 9.4.2 to 9.6.12

2019-07-04 Thread Ashwini Singh
Hi Everyone, We have a legacy application running on Ruby on Rails on AWS infrastructure. We wanted to do a DB upgrade from PostgreSQL version 9.4.2 to 9.6.12. We tried finding out any breaking changes from 9.4.x to 9.6.x upgrade but could not find out by reading the documentation. Please let us

Re: Expression of check constraint

2019-07-04 Thread Tom Lane
Dirk Mika writes: > 3.The column ratified is of type character varying(1). Why is it casted > to text? Type varchar in Postgres is a poor stepchild without any operators of its own. Text is the "native" string type and any comparison etc will require casting varchar to text first. It happ

Re: Error: rows returned by function are not all of the same row type

2019-07-04 Thread Tom Lane
Andrey Sychev writes: > I have written C-language function that returns > multiple composite rows. > Generally function works as expected, but sometimes problem takes place. > At rough guess the problem occurs when number of returning rows > relatively large (more than 100K - 1M). I do not

Why does jsonb_set() remove non-mentioned keys?

2019-07-04 Thread Thomas Kellerer
Why does select jsonb_set('{"foo": 1}'::jsonb, '{bar}', to_jsonb(null::int), true) return NULL when all it should do is to add a second key? I would expect {"foo": 1, "bar": null} or no change at all to the original JSON value, but not that the whole JSON is set to null. In the original c

Error: rows returned by function are not all of the same row type

2019-07-04 Thread Andrey Sychev
Hi, everyone, I have written C-language function that returns multiple composite rows. Generally function works as expected, but sometimes problem takes place. At rough guess the problem occurs when number of returning rows relatively large (more than 100K - 1M). I have added some checkpo

Re: Expression of check constraint

2019-07-04 Thread Laurenz Albe
Dirk Mika wrote: > if I add the following check constraint to a table: > > ALTER TABLE public.times_places >ADD CONSTRAINT ck_tp_ratified CHECK > (ratified IS NULL OR (ratified IN ('Y', 'N'))); > > It becomes the following when describing the table in psql: > > Check constraints

Help with a selection

2019-07-04 Thread paul.malm
Hi, I have a column named col (varchar) col could look like this 902930 902920 902900 903110 913210 913200 ... I would like to remove an object that doesn't end '00' and if there are objects that start with the same 4 charcters and ending with 00. All objects ending with 00 shall remain. All obje

Re: Expression of check constraint

2019-07-04 Thread Dirk Mika
Hi -- Dirk Mika Software Developer mika:timing GmbH Strundepark - Kürtener Str. 11b 51465 Bergisch Gladbach Germany fon +49 2202 2401-1197 dirk.m...@mikatiming.de www.mikatiming.de AG Köln HRB 47509 * WEEE-Reg.-Nr. DE 90029884 Geschäftsführer: Harald Mika, Jörg Mika ## How2Use ## the Champi

Re: Expression of check constraint

2019-07-04 Thread rob stone
Hello, On Thu, 2019-07-04 at 05:58 +, Dirk Mika wrote: > Hi, > > if I add the following check constraint to a table: > > ALTER TABLE public.times_places >ADD CONSTRAINT ck_tp_ratified CHECK > (ratified IS NULL OR (ratified IN ('Y', 'N'))); > > It becomes the following when