Skip to content

Commit 26d905a

Browse files
committed
Use SET TRANSACTION READ ONLY in pg_dump, if server supports it.
This currently does little except serve as documentation. (The one case where it has a performance benefit, SERIALIZABLE mode in 9.1 and up, was already using READ ONLY mode.) However, it's possible that it might have performance benefits in future, and in any case it seems like good practice since it would catch any accidentally non-read-only operations. Pavan Deolasee
1 parent 4b94cfb commit 26d905a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,14 @@ main(int argc, char **argv)
618618
else
619619
ExecuteSqlStatement(fout,
620620
"SET TRANSACTION ISOLATION LEVEL "
621-
"REPEATABLE READ");
621+
"REPEATABLE READ, READ ONLY");
622+
}
623+
else if (fout->remoteVersion >= 70400)
624+
{
625+
/* note: comma was not accepted in SET TRANSACTION before 8.0 */
626+
ExecuteSqlStatement(fout,
627+
"SET TRANSACTION ISOLATION LEVEL "
628+
"SERIALIZABLE READ ONLY");
622629
}
623630
else
624631
ExecuteSqlStatement(fout,

0 commit comments

Comments
 (0)