[GENERAL] Re: "alter table...if exists... add bigserial "still adds extra sequence
> On 25 Sep 2017, at 09:51 , hvjunk <hvj...@gmail.com> wrote: > > Good day, > > See the sequence below, Postgresql 9.6.5 on Debian using the postgresql > repository. > > Question: Is this expected behaviour? I guess it might be, but the “bug” is that the excessive/unused sequence isn’t removed: test=# \d test_serial Table "public.test_serial" Column | Type | Modifiers +--+--- teststring | character varying(5) | uid| bigint | not null default nextval('test_serial_uid_seq'::regclass) > > > > postgres@tracsdbhvt01:~$ cat test-serial.sql > create database test; > \c test > create table test_serial ( teststring varchar(5)); > alter table test_serial add column if not exists uid BIGSERIAL; > alter table test_serial add column if not exists uid BIGSERIAL; > \d > > postgres@tracsdbhvt01:~$ psql -p 5433 < test-serial.sql > CREATE DATABASE > You are now connected to database "test" as user "postgres". > CREATE TABLE > ALTER TABLE > NOTICE: column "uid" of relation "test_serial" already exists, skipping > ALTER TABLE > List of relations > Schema | Name | Type | Owner > +--+--+-- > public | test_serial | table| postgres > public | test_serial_uid_seq | sequence | postgres > public | test_serial_uid_seq1 | sequence | postgres > (3 rows) > > -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
[GENERAL] "alter table...if exists... add bigserial "still adds extra sequence
Good day, See the sequence below, Postgresql 9.6.5 on Debian using the postgresql repository. Question: Is this expected behaviour? postgres@tracsdbhvt01:~$ cat test-serial.sql create database test; \c test create table test_serial ( teststring varchar(5)); alter table test_serial add column if not exists uid BIGSERIAL; alter table test_serial add column if not exists uid BIGSERIAL; \d postgres@tracsdbhvt01:~$ psql -p 5433 < test-serial.sql CREATE DATABASE You are now connected to database "test" as user "postgres". CREATE TABLE ALTER TABLE NOTICE: column "uid" of relation "test_serial" already exists, skipping ALTER TABLE List of relations Schema | Name | Type | Owner +--+--+-- public | test_serial | table| postgres public | test_serial_uid_seq | sequence | postgres public | test_serial_uid_seq1 | sequence | postgres (3 rows) -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
[GENERAL] pg_start/stop_backup non-exclusive scripts to snapshot
Hi there, I’ve previously done ZFS snapshot backups like this: psql -c “select pg_start_backup(‘snapshot’);” zfs snapshot TANK/postgresql@`date ‘+%Ymd’` psql -c “select * from pg_stop_backup();” Reading the PostgreSQL9.6 documentation, the advice/future is to use the non-exclusive method, where I’ll need to keep a session *open* while the snapshot takes place, and after that I’ll have to issue the pg_stop_backup(false); in that active connection that issued the pg_start_backup(‘backup’,false,false); How is this done inside a shell script? Especially how to do error checking from the commands as psql -c “select pg_start_backup{‘test’,false,false);” not going to work? Hendrik -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general
Re: [GENERAL] current postgresql logfile being written to?
> On 22 Jun 2017, at 04:44 , Lucas Possamai <drum.lu...@gmail.com> wrote: > > > > 2017-06-22 14:16 GMT+12:00 hvjunk <hvj...@gmail.com > <mailto:hvj...@gmail.com>>: > >> On 22 Jun 2017, at 4:06 AM, Lucas Possamai <drum.lu...@gmail.com >> <mailto:drum.lu...@gmail.com>> wrote: >> >> >> >> 2017-06-22 13:54 GMT+12:00 hvjunk <hvj...@gmail.com >> <mailto:hvj...@gmail.com>>: >> Hi there, >> >> I was hoping for a method (like archive_command) to handle logfile >> processing/archiving/compression, but unless doing it the logrotate way, I >> don’t see anything that postgresql provides. Is that correct? >> >> The closest I could find is: pg_rotate_logfile()… but here my question is >> where do I find the current active logfile(s) that postgresql is currently >> writing to? >> (At least that way I can handle all the files that that postgresql is not >> writing to :) ) >> >> Hendrik >> >> >> >> I use logging_collector + log_rotation_age + log_filename + >> log_min_duration_statement [1] >> >> Using those options PG automatically rotates and keep them for a week or >> more if you specified it. >> >> [1] https://www.postgresql.org/docs/9.6/static/runtime-config-logging.html >> <https://www.postgresql.org/docs/9.6/static/runtime-config-logging.html> >> > > That I know, but which file is the postgresql server/cluster writing to right > now? > > > > On your postgresql.conf check log_directory. If it's the default, then: > /var/log/postgresql Okay Lucas, I’m looking at my log directory: -rw--- 1 postgres postgres 1002231184 Jun 22 11:08 postgresql-2017-06-22_001050.log -rw--- 1 postgres postgres 1073742619 Jun 22 11:08 postgresql-2017-06-22_001045.log my log snippets: # These are only used if logging_collector is on: log_directory = '/var/log/postgresql/' log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' log_file_mode = 0600 log_truncate_on_rotation = off log_rotation_age = 1h log_rotation_size = 1GB So which one is postgresql actually writing to right now? (no guessing, and the name might be a clue, but that is guessing IMHO)
Re: [GENERAL] current postgresql logfile being written to?
> On 22 Jun 2017, at 4:06 AM, Lucas Possamai <drum.lu...@gmail.com> wrote: > > > > 2017-06-22 13:54 GMT+12:00 hvjunk <hvj...@gmail.com > <mailto:hvj...@gmail.com>>: > Hi there, > > I was hoping for a method (like archive_command) to handle logfile > processing/archiving/compression, but unless doing it the logrotate way, I > don’t see anything that postgresql provides. Is that correct? > > The closest I could find is: pg_rotate_logfile()… but here my question is > where do I find the current active logfile(s) that postgresql is currently > writing to? > (At least that way I can handle all the files that that postgresql is not > writing to :) ) > > Hendrik > > > > I use logging_collector + log_rotation_age + log_filename + > log_min_duration_statement [1] > > Using those options PG automatically rotates and keep them for a week or more > if you specified it. > > [1] https://www.postgresql.org/docs/9.6/static/runtime-config-logging.html > <https://www.postgresql.org/docs/9.6/static/runtime-config-logging.html> > That I know, but which file is the postgresql server/cluster writing to right now?
[GENERAL] current postgresql logfile being written to?
Hi there, I was hoping for a method (like archive_command) to handle logfile processing/archiving/compression, but unless doing it the logrotate way, I don’t see anything that postgresql provides. Is that correct? The closest I could find is: pg_rotate_logfile()… but here my question is where do I find the current active logfile(s) that postgresql is currently writing to? (At least that way I can handle all the files that that postgresql is not writing to :) ) Hendrik -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general