Re: How to Straming replication chatch up from archive

2023-12-13 Thread Filip Sedlák

> if the master overwrite the wal BEFORE they are sent to the standby via
> replication, does the standby *automatically* start looking in WAL
> archive destination?
> Or this step have to be made by hand?

I understand it works this way: normally, the replica tries to stream 
from master. If it is not able to (for example, the requested WAL has 
been already rotated), then it tries to call the restore_command.


See 
https://www.postgresql.org/docs/current/continuous-archiving.html#BACKUP-PITR-RECOVERY


So you just need to specify where the older WALs are. For example

restore_command = 'cp /mnt/nfs/archivedir/%f %p'

assuming the server has a similar archive_command that stores WALs into 
that directory.


--
Filip Sedlák





Re: Emitting JSON to file using COPY TO

2023-11-27 Thread Filip Sedlák
This would be a very special case for COPY. It applies only to a single 
column of JSON values. The original problem can be solved with psql 
--tuples-only as David wrote earlier.



$ psql -tc 'select json_agg(row_to_json(t))
 from (select * from public.tbl_json_test) t;'

 [{"id":1,"t_test":"here's a \"string\""}]


Special-casing any encoding/escaping scheme leads to bugs and harder 
parsing.


Just my 2c.

--
Filip Sedlák