Empty tablespace directory after restore with psql -d dbname -f dump.sql

2021-05-14 Thread frank picabia
We cancelled a web application upgrade part way through when it was realized Postgres needed a version upgrade first. Using the dump file extracted from a full dump with pg_dumpall the DB was restored with a line like : psql -d dbname -f dump.sql The file dump.sql was extracted from the full du

Re: Question about integer out of range in function

2021-05-14 Thread Condor
On 14-05-2021 17:42, Tom Lane wrote: Condor writes: new_time = fromtime * 1000; -- here is line 19 Are you entirely certain that you counted lines correctly? If new_time and fromtime are both declared bigint, and fromtime is on the order of # select extract(epoch from now())::bigint;

Re: RETURNING, CTEs and TRANSACTION ISOLATION levels...

2021-05-14 Thread Francisco Olarte
One little comment. On Fri, May 14, 2021 at 5:33 PM Pól Ua Laoínecháin wrote: > I was trying to do this: > DELETE FROM t > WHERE id IN > INSERT INTO t_archiv > ( > SELECT * > FROM t > WHERE EXTRACT(EPOCH FROM NOW()) - epok > 15613200 > ) > RETURNING id; ... The complex stuf

Re: Query on postgres_fdw extension

2021-05-14 Thread Laurenz Albe
On Fri, 2021-05-14 at 10:53 -0400, Tom Lane wrote: > Swathi P writes: > > Hence we decided to have the coordinator nodes as stateless and hence > > declared the column with no serial/sequence. Let me know if this makes > > sense. > > Attaching serial-sequence defaults on both sides would certainl

Re: RETURNING, CTEs and TRANSACTION ISOLATION levels...

2021-05-14 Thread David G. Johnston
On Fri, May 14, 2021 at 8:33 AM Pól Ua Laoínecháin wrote: > > I was able to do it by chaining CTEs - but I wanted to be sure that > when chaining CTEs, all work done in a statement with multiple > modifications to data was done within the same transaction - this is > what I thought my SQL would d

Re: RETURNING, CTEs and TRANSACTION ISOLATION levels...

2021-05-14 Thread Tom Lane
=?UTF-8?B?UMOzbCBVYSBMYW/DrW5lY2jDoWlu?= writes: > I was trying to do this: > DELETE FROM t > WHERE id IN > INSERT INTO t_archiv > ( > SELECT * > FROM t > WHERE EXTRACT(EPOCH FROM NOW()) - epok > 15613200 > ) > RETURNING id; Try putting the INSERT ... RETURNING in a CTE (WITH

RETURNING, CTEs and TRANSACTION ISOLATION levels...

2021-05-14 Thread Pól Ua Laoínecháin
Hi all, I was trying to do this: DELETE FROM t WHERE id IN INSERT INTO t_archiv ( SELECT * FROM t WHERE EXTRACT(EPOCH FROM NOW()) - epok > 15613200 ) RETURNING id; see the fiddle here: https://dbfiddle.uk/?rdbms=postgres_12&fiddle=d3cb601af2e4c99a32c56df03f97a5f2 This works

Re: Query on postgres_fdw extension

2021-05-14 Thread Tom Lane
Bharath Rupireddy writes: > On Fri, May 14, 2021 at 8:23 PM Tom Lane wrote: >> One conceivable workaround is to do your insertions through a >> foreign table that doesn't even have the serial column, so that >> the INSERT command received by the remote server lacks that >> column and the default

Re: Query on postgres_fdw extension

2021-05-14 Thread Bharath Rupireddy
On Fri, May 14, 2021 at 8:23 PM Tom Lane wrote: > > [ removing -bugs ] > > Swathi P writes: > > Hence we decided to have the coordinator nodes as stateless and hence > > declared the column with no serial/sequence. Let me know if this makes > > sense. > > Attaching serial-sequence defaults on bot

Re: Query on postgres_fdw extension

2021-05-14 Thread Bharath Rupireddy
On Fri, May 14, 2021 at 12:37 PM Swathi P wrote: > > Thanks Bharath for the details. > > In our sharding solution, we have multiple coodinator nodes. If we declare > the table column as serial data type, we might end up having duplicate values > for id column in the table_a in host_b (data node)

Re: Query on postgres_fdw extension

2021-05-14 Thread Tom Lane
[ removing -bugs ] Swathi P writes: > Hence we decided to have the coordinator nodes as stateless and hence > declared the column with no serial/sequence. Let me know if this makes > sense. Attaching serial-sequence defaults on both sides would certainly not work very well, because the sequences

Re: Same column names in a subresult table

2021-05-14 Thread David G. Johnston
On Friday, May 14, 2021, Durumdara wrote: > > Is there any way to suppress the original field? > Remove the star and list the other columns you do want. > > Or say to PGSQL to skip the first XDate field? > > Like select t.* (EXCEPT XDate) from t > No, though I’ve expressed a desire for this

Re: Question about integer out of range in function

2021-05-14 Thread Tom Lane
Condor writes: > new_time = fromtime * 1000; -- here is line 19 Are you entirely certain that you counted lines correctly? If new_time and fromtime are both declared bigint, and fromtime is on the order of # select extract(epoch from now())::bigint; extract 1621003124 (1

Re: Same column names in a subresult table

2021-05-14 Thread Rory Campbell-Lange
On 14/05/21, Durumdara (durumd...@gmail.com) wrote: > ... > midqry1 as ( > select coalesce(XDate , '0001-01-01'), * from prevqry > ), > midqry2 as ( > select ArtID, max(XDate) as Max_XDate from midqry1 > where acq = True > group by ArtID > ) > ... > > Result: ERROR: column reference "XDate

Same column names in a subresult table

2021-05-14 Thread Durumdara
Hello! I have a big "WITH QUERY", with many subqueries. I have a date field, named "XDate". In the middle I duplicated this field: ... midqry1 as ( select coalesce(XDate , '0001-01-01'), * from prevqry ), midqry2 as ( select ArtID, max(XDate) as Max_XDate from midqry1 where acq = True

Re: Query on postgres_fdw extension

2021-05-14 Thread Swathi P
Thanks Bharath for the details. In our sharding solution, we have multiple coodinator nodes. If we declare the table column as serial data type, we might end up having duplicate values for id column in the table_a in host_b (data node) as cconnections come from multiple coordinatoor nodes and migh

Re: Question about integer out of range in function

2021-05-14 Thread Ron
On 5/14/21 1:38 AM, Condor wrote: Hello ppl, I have a question about ERROR:  integer out of range in one function. I modify the generate_ulid() function to accept also UNIX timestamp as input parameter. I drop old function and make new one: CREATE FUNCTION generate_ulid(fromtime bigint defa

Re: Query on postgres_fdw extension

2021-05-14 Thread Bharath Rupireddy
On Thu, May 13, 2021 at 4:58 PM Swathi P wrote: > > Hello EveryOne, > > Hope you are all doing well and staying safe. > > Am Swathi, have been working with postgres for last 3 years. Currently we are > working on a project to build a sharding solution with the help of native > postgres_fdw exte