pg_dump_grouplock.patch
application/octet-stream
Filename: pg_dump_grouplock.patch
Type: application/octet-stream
Part: 0
Message:
Re: pg_dump and thousands of schemas
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/bin/pg_dump/pg_dump.c | 0 | 0 |
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
new file mode 100644
index d9aeee3..4f5eec3
*** a/src/bin/pg_dump/pg_dump.c
--- b/src/bin/pg_dump/pg_dump.c
*************** getTables(Archive *fout, int *numTables)
*** 3833,3838 ****
--- 3833,3839 ----
int i_reloptions;
int i_toastreloptions;
int i_reloftype;
+ bool lock_needed = false;
/* Make sure we are in proper schema */
selectSourceSchema(fout, "pg_catalog");
*************** getTables(Archive *fout, int *numTables)
*** 4274,4288 ****
* NOTE: it'd be kinda nice to lock other relations too, not only
* plain tables, but the backend doesn't presently allow that.
*/
! if (tblinfo[i].dobj.dump && tblinfo[i].relkind == RELKIND_RELATION)
{
resetPQExpBuffer(query);
! appendPQExpBuffer(query,
! "LOCK TABLE %s IN ACCESS SHARE MODE",
! fmtQualifiedId(fout,
tblinfo[i].dobj.namespace->dobj.name,
! tblinfo[i].dobj.name));
! ExecuteSqlStatement(fout, query->data);
}
/* Emit notice if join for owner failed */
--- 4275,4295 ----
* NOTE: it'd be kinda nice to lock other relations too, not only
* plain tables, but the backend doesn't presently allow that.
*/
! if (i == 0)
{
resetPQExpBuffer(query);
! appendPQExpBuffer(query,"LOCK TABLE ");
! }
!
! if (tblinfo[i].dobj.dump && tblinfo[i].relkind == RELKIND_RELATION)
! {
! if (lock_needed)
! appendPQExpBuffer(query,",");
! appendPQExpBuffer(query,"%s",
! fmtQualifiedId(fout,
tblinfo[i].dobj.namespace->dobj.name,
! tblinfo[i].dobj.name));
! lock_needed = true;
}
/* Emit notice if join for owner failed */
*************** getTables(Archive *fout, int *numTables)
*** 4291,4296 ****
--- 4298,4309 ----
tblinfo[i].dobj.name);
}
+ if (lock_needed)
+ {
+ appendPQExpBuffer(query, " IN ACCESS SHARE MODE");
+ ExecuteSqlStatement(fout, query->data);
+ }
+
if (lockWaitTimeout && fout->remoteVersion >= 70300)
{
ExecuteSqlStatement(fout, "SET statement_timeout = 0");