Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/backend/commands/dbcommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,6 @@ CreateDirAndVersionFile(char *dbpath, Oid dbid, Oid tsid, bool isRedo)

lsn = XLogInsert(RM_DBASE_ID, XLOG_DBASE_CREATE_WAL_LOG);

SetLastWrittenLSNForDatabase(lsn);

/* As always, WAL must hit the disk before the data update does. */
XLogFlush(lsn);
}
Expand Down Expand Up @@ -615,7 +613,6 @@ CreateDatabaseUsingFileCopy(Oid src_dboid, Oid dst_dboid, Oid src_tsid,
/* Record the filesystem change in XLOG */
{
xl_dbase_create_file_copy_rec xlrec;
XLogRecPtr lsn;

xlrec.db_id = dst_dboid;
xlrec.tablespace_id = dsttablespace;
Expand All @@ -626,10 +623,8 @@ CreateDatabaseUsingFileCopy(Oid src_dboid, Oid dst_dboid, Oid src_tsid,
XLogRegisterData((char *) &xlrec,
sizeof(xl_dbase_create_file_copy_rec));

lsn = XLogInsert(RM_DBASE_ID,
(void) XLogInsert(RM_DBASE_ID,
XLOG_DBASE_CREATE_FILE_COPY | XLR_SPECIAL_REL_UPDATE);

SetLastWrittenLSNForDatabase(lsn);
}
pfree(srcpath);
pfree(dstpath);
Expand Down Expand Up @@ -1403,6 +1398,11 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
CreateDatabaseUsingFileCopy(src_dboid, dboid, src_deftablespace,
dst_deftablespace);

/*
* Update global last written LSN after wal-logging create database command
*/
SetLastWrittenLSNForDatabase(XactLastRecEnd);

/*
* Close pg_database, but keep lock till commit.
*/
Expand Down