Commit a36a8fa3 authored by Andres Freund's avatar Andres Freund

Rename logical decoding's pg_llog directory to pg_logical.

The old name wasn't very descriptive as of actual contents of the
directory, which are historical snapshots in the snapshots/
subdirectory and mappingdata for rewritten tuples in
mappings/. There's been a fair amount of discussion what would be a
good name. I'm settling for pg_logical because it's likely that
further data around logical decoding and replication will need saving
in the future.

Also add the missing entry for the directory into storage.sgml's list
of PGDATA contents.

Bumps catversion as the data directories won't be compatible.
parent 89cf2d52
...@@ -77,6 +77,11 @@ Item ...@@ -77,6 +77,11 @@ Item
subsystem</entry> subsystem</entry>
</row> </row>
<row>
<entry><filename>pg_logical</></entry>
<entry>Subdirectory containing status data for logical decoding</entry>
</row>
<row> <row>
<entry><filename>pg_multixact</></entry> <entry><filename>pg_multixact</></entry>
<entry>Subdirectory containing multitransaction status data <entry>Subdirectory containing multitransaction status data
......
...@@ -1009,7 +1009,7 @@ logical_rewrite_log_mapping(RewriteState state, TransactionId xid, ...@@ -1009,7 +1009,7 @@ logical_rewrite_log_mapping(RewriteState state, TransactionId xid,
dboid = MyDatabaseId; dboid = MyDatabaseId;
snprintf(path, MAXPGPATH, snprintf(path, MAXPGPATH,
"pg_llog/mappings/" LOGICAL_REWRITE_FORMAT, "pg_logical/mappings/" LOGICAL_REWRITE_FORMAT,
dboid, relid, dboid, relid,
(uint32) (state->rs_begin_lsn >> 32), (uint32) (state->rs_begin_lsn >> 32),
(uint32) state->rs_begin_lsn, (uint32) state->rs_begin_lsn,
...@@ -1133,7 +1133,7 @@ heap_xlog_logical_rewrite(XLogRecPtr lsn, XLogRecord *r) ...@@ -1133,7 +1133,7 @@ heap_xlog_logical_rewrite(XLogRecPtr lsn, XLogRecord *r)
xlrec = (xl_heap_rewrite_mapping *) XLogRecGetData(r); xlrec = (xl_heap_rewrite_mapping *) XLogRecGetData(r);
snprintf(path, MAXPGPATH, snprintf(path, MAXPGPATH,
"pg_llog/mappings/" LOGICAL_REWRITE_FORMAT, "pg_logical/mappings/" LOGICAL_REWRITE_FORMAT,
xlrec->mapped_db, xlrec->mapped_rel, xlrec->mapped_db, xlrec->mapped_rel,
(uint32) (xlrec->start_lsn >> 32), (uint32) (xlrec->start_lsn >> 32),
(uint32) xlrec->start_lsn, (uint32) xlrec->start_lsn,
...@@ -1219,8 +1219,8 @@ CheckPointLogicalRewriteHeap(void) ...@@ -1219,8 +1219,8 @@ CheckPointLogicalRewriteHeap(void)
if (cutoff != InvalidXLogRecPtr && redo < cutoff) if (cutoff != InvalidXLogRecPtr && redo < cutoff)
cutoff = redo; cutoff = redo;
mappings_dir = AllocateDir("pg_llog/mappings"); mappings_dir = AllocateDir("pg_logical/mappings");
while ((mapping_de = ReadDir(mappings_dir, "pg_llog/mappings")) != NULL) while ((mapping_de = ReadDir(mappings_dir, "pg_logical/mappings")) != NULL)
{ {
struct stat statbuf; struct stat statbuf;
Oid dboid; Oid dboid;
...@@ -1235,7 +1235,7 @@ CheckPointLogicalRewriteHeap(void) ...@@ -1235,7 +1235,7 @@ CheckPointLogicalRewriteHeap(void)
strcmp(mapping_de->d_name, "..") == 0) strcmp(mapping_de->d_name, "..") == 0)
continue; continue;
snprintf(path, MAXPGPATH, "pg_llog/mappings/%s", mapping_de->d_name); snprintf(path, MAXPGPATH, "pg_logical/mappings/%s", mapping_de->d_name);
if (lstat(path, &statbuf) == 0 && !S_ISREG(statbuf.st_mode)) if (lstat(path, &statbuf) == 0 && !S_ISREG(statbuf.st_mode))
continue; continue;
......
...@@ -2788,7 +2788,7 @@ ApplyLogicalMappingFile(HTAB *tuplecid_data, Oid relid, const char *fname) ...@@ -2788,7 +2788,7 @@ ApplyLogicalMappingFile(HTAB *tuplecid_data, Oid relid, const char *fname)
int readBytes; int readBytes;
LogicalRewriteMappingData map; LogicalRewriteMappingData map;
sprintf(path, "pg_llog/mappings/%s", fname); sprintf(path, "pg_logical/mappings/%s", fname);
fd = OpenTransientFile(path, O_RDONLY | PG_BINARY, 0); fd = OpenTransientFile(path, O_RDONLY | PG_BINARY, 0);
if (fd < 0) if (fd < 0)
ereport(ERROR, ereport(ERROR,
...@@ -2908,8 +2908,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot) ...@@ -2908,8 +2908,8 @@ UpdateLogicalMappings(HTAB *tuplecid_data, Oid relid, Snapshot snapshot)
size_t off; size_t off;
Oid dboid = IsSharedRelation(relid) ? InvalidOid : MyDatabaseId; Oid dboid = IsSharedRelation(relid) ? InvalidOid : MyDatabaseId;
mapping_dir = AllocateDir("pg_llog/mappings"); mapping_dir = AllocateDir("pg_logical/mappings");
while ((mapping_de = ReadDir(mapping_dir, "pg_llog/mappings")) != NULL) while ((mapping_de = ReadDir(mapping_dir, "pg_logical/mappings")) != NULL)
{ {
Oid f_dboid; Oid f_dboid;
Oid f_relid; Oid f_relid;
......
...@@ -1452,7 +1452,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn) ...@@ -1452,7 +1452,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn)
* unless the user used pg_resetxlog or similar. If a user did so, there's * unless the user used pg_resetxlog or similar. If a user did so, there's
* no hope continuing to decode anyway. * no hope continuing to decode anyway.
*/ */
sprintf(path, "pg_llog/snapshots/%X-%X.snap", sprintf(path, "pg_logical/snapshots/%X-%X.snap",
(uint32) (lsn >> 32), (uint32) lsn); (uint32) (lsn >> 32), (uint32) lsn);
/* /*
...@@ -1478,7 +1478,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn) ...@@ -1478,7 +1478,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn)
* be safely on disk. * be safely on disk.
*/ */
fsync_fname(path, false); fsync_fname(path, false);
fsync_fname("pg_llog/snapshots", true); fsync_fname("pg_logical/snapshots", true);
builder->last_serialized_snapshot = lsn; builder->last_serialized_snapshot = lsn;
goto out; goto out;
...@@ -1494,7 +1494,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn) ...@@ -1494,7 +1494,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn)
elog(DEBUG1, "serializing snapshot to %s", path); elog(DEBUG1, "serializing snapshot to %s", path);
/* to make sure only we will write to this tempfile, include pid */ /* to make sure only we will write to this tempfile, include pid */
sprintf(tmppath, "pg_llog/snapshots/%X-%X.snap.%u.tmp", sprintf(tmppath, "pg_logical/snapshots/%X-%X.snap.%u.tmp",
(uint32) (lsn >> 32), (uint32) lsn, MyProcPid); (uint32) (lsn >> 32), (uint32) lsn, MyProcPid);
/* /*
...@@ -1580,7 +1580,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn) ...@@ -1580,7 +1580,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn)
} }
CloseTransientFile(fd); CloseTransientFile(fd);
fsync_fname("pg_llog/snapshots", true); fsync_fname("pg_logical/snapshots", true);
/* /*
* We may overwrite the work from some other backend, but that's ok, our * We may overwrite the work from some other backend, but that's ok, our
...@@ -1596,7 +1596,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn) ...@@ -1596,7 +1596,7 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn)
/* make sure we persist */ /* make sure we persist */
fsync_fname(path, false); fsync_fname(path, false);
fsync_fname("pg_llog/snapshots", true); fsync_fname("pg_logical/snapshots", true);
/* /*
* Now there's no way we can loose the dumped state anymore, remember this * Now there's no way we can loose the dumped state anymore, remember this
...@@ -1627,7 +1627,7 @@ SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn) ...@@ -1627,7 +1627,7 @@ SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn)
if (builder->state == SNAPBUILD_CONSISTENT) if (builder->state == SNAPBUILD_CONSISTENT)
return false; return false;
sprintf(path, "pg_llog/snapshots/%X-%X.snap", sprintf(path, "pg_logical/snapshots/%X-%X.snap",
(uint32) (lsn >> 32), (uint32) lsn); (uint32) (lsn >> 32), (uint32) lsn);
fd = OpenTransientFile(path, O_RDONLY | PG_BINARY, 0); fd = OpenTransientFile(path, O_RDONLY | PG_BINARY, 0);
...@@ -1648,7 +1648,7 @@ SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn) ...@@ -1648,7 +1648,7 @@ SnapBuildRestore(SnapBuild *builder, XLogRecPtr lsn)
* ---- * ----
*/ */
fsync_fname(path, false); fsync_fname(path, false);
fsync_fname("pg_llog/snapshots", true); fsync_fname("pg_logical/snapshots", true);
/* read statically sized portion of snapshot */ /* read statically sized portion of snapshot */
...@@ -1825,8 +1825,8 @@ CheckPointSnapBuild(void) ...@@ -1825,8 +1825,8 @@ CheckPointSnapBuild(void)
if (redo < cutoff) if (redo < cutoff)
cutoff = redo; cutoff = redo;
snap_dir = AllocateDir("pg_llog/snapshots"); snap_dir = AllocateDir("pg_logical/snapshots");
while ((snap_de = ReadDir(snap_dir, "pg_llog/snapshots")) != NULL) while ((snap_de = ReadDir(snap_dir, "pg_logical/snapshots")) != NULL)
{ {
uint32 hi; uint32 hi;
uint32 lo; uint32 lo;
...@@ -1837,7 +1837,7 @@ CheckPointSnapBuild(void) ...@@ -1837,7 +1837,7 @@ CheckPointSnapBuild(void)
strcmp(snap_de->d_name, "..") == 0) strcmp(snap_de->d_name, "..") == 0)
continue; continue;
snprintf(path, MAXPGPATH, "pg_llog/snapshots/%s", snap_de->d_name); snprintf(path, MAXPGPATH, "pg_logical/snapshots/%s", snap_de->d_name);
if (lstat(path, &statbuf) == 0 && !S_ISREG(statbuf.st_mode)) if (lstat(path, &statbuf) == 0 && !S_ISREG(statbuf.st_mode))
{ {
......
...@@ -199,9 +199,9 @@ static const char *subdirs[] = { ...@@ -199,9 +199,9 @@ static const char *subdirs[] = {
"pg_tblspc", "pg_tblspc",
"pg_stat", "pg_stat",
"pg_stat_tmp", "pg_stat_tmp",
"pg_llog", "pg_logical",
"pg_llog/snapshots", "pg_logical/snapshots",
"pg_llog/mappings" "pg_logical/mappings"
}; };
......
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 201406292 #define CATALOG_VERSION_NO 201407021
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment