diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2010-01-20 19:43:40 +0000 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2010-01-20 19:43:40 +0000 |
commit | 09b115f70684ea20dc344faab1a96f2831d3ee75 (patch) | |
tree | 97ee9e81891d786e815ebc0e7e69a293f212fd5d /src/backend/commands/tablecmds.c | |
parent | 47ce95a7b98ff06b51f12a7381fc3788dff9961c (diff) | |
download | postgresql-09b115f70684ea20dc344faab1a96f2831d3ee75.tar.gz postgresql-09b115f70684ea20dc344faab1a96f2831d3ee75.zip |
Write a WAL record whenever we perform an operation without WAL-logging
that would've been WAL-logged if archiving was enabled. If we encounter
such records in archive recovery anyway, we know that some data is
missing from the log. A WARNING is emitted in that case.
Original patch by Fujii Masao, with changes by me.
Diffstat (limited to 'src/backend/commands/tablecmds.c')
-rw-r--r-- | src/backend/commands/tablecmds.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 43d8c0c56bf..0c5ccdcb45e 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.316 2010/01/17 22:56:21 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.317 2010/01/20 19:43:40 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -7015,6 +7015,19 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace) heap_close(pg_class, RowExclusiveLock); + /* + * Write an XLOG UNLOGGED record if WAL-logging was skipped because + * WAL archiving is not enabled. + */ + if (!XLogIsNeeded() && !rel->rd_istemp) + { + char reason[NAMEDATALEN + 40]; + snprintf(reason, sizeof(reason), "ALTER TABLE SET TABLESPACE on \"%s\"", + RelationGetRelationName(rel)); + + XLogReportUnloggedStatement(reason); + } + relation_close(rel, NoLock); /* Make sure the reltablespace change is visible */ @@ -7043,6 +7056,10 @@ copy_relation_data(SMgrRelation src, SMgrRelation dst, /* * We need to log the copied data in WAL iff WAL archiving/streaming is * enabled AND it's not a temp rel. + * + * Note: If you change the conditions here, update the conditions in + * ATExecSetTableSpace() for when an XLOG UNLOGGED record is written + * to match. */ use_wal = XLogIsNeeded() && !istemp; |