Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfa3840c

Browse files
committed
Revert "pg_dump: Lock all relations, not just plain tables".
Revert 403a3d91c, as well as the followup fix 7f4235032, in allbranches. We need to think a bit harder about what the behaviorof LOCK TABLE on views should be, and there's no time for thatbefore next week's releases. We'll take another crack at thislater.Discussion:https://postgr.es/m/16703-e348f58aab3cf6cc@postgresql.org
1 parent44b973b commitfa3840c

File tree

4 files changed

+7
-80
lines changed

4 files changed

+7
-80
lines changed

‎src/bin/pg_dump/pg_backup.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ typedef struct Archive
198198
intminRemoteVersion;/* allowable range */
199199
intmaxRemoteVersion;
200200

201-
boolhasGenericLockTable;/* can LOCK TABLE do non-table rels */
202-
203201
intnumWorkers;/* number of parallel processes */
204202
char*sync_snapshot_id;/* sync snapshot id for parallel operation */
205203

‎src/bin/pg_dump/pg_backup_db.c‎

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -532,72 +532,6 @@ EndDBCopyMode(Archive *AHX, const char *tocEntryTag)
532532
}
533533
}
534534

535-
/*
536-
* Does LOCK TABLE work on non-table relations on this server?
537-
*
538-
* Note: assumes it is called out of any transaction
539-
*/
540-
bool
541-
IsLockTableGeneric(Archive*AHX)
542-
{
543-
ArchiveHandle*AH= (ArchiveHandle*)AHX;
544-
PGresult*res;
545-
char*sqlstate;
546-
boolretval;
547-
548-
if (AHX->remoteVersion >=140000)
549-
return true;
550-
elseif (AHX->remoteVersion<90500)
551-
return false;
552-
553-
StartTransaction(AHX);
554-
555-
/*
556-
* Try a LOCK TABLE on a well-known non-table catalog; WRONG_OBJECT_TYPE
557-
* tells us that this server doesn't support locking non-table rels, while
558-
* LOCK_NOT_AVAILABLE and INSUFFICIENT_PRIVILEGE tell us that it does.
559-
* Report anything else as a fatal problem.
560-
*/
561-
#defineERRCODE_INSUFFICIENT_PRIVILEGE"42501"
562-
#defineERRCODE_WRONG_OBJECT_TYPE"42809"
563-
#defineERRCODE_LOCK_NOT_AVAILABLE"55P03"
564-
res=PQexec(AH->connection,
565-
"LOCK TABLE pg_catalog.pg_class_tblspc_relfilenode_index IN ACCESS SHARE MODE NOWAIT");
566-
switch (PQresultStatus(res))
567-
{
568-
casePGRES_COMMAND_OK:
569-
retval= true;
570-
break;
571-
casePGRES_FATAL_ERROR:
572-
sqlstate=PQresultErrorField(res,PG_DIAG_SQLSTATE);
573-
if (sqlstate&&
574-
strcmp(sqlstate,ERRCODE_WRONG_OBJECT_TYPE)==0)
575-
{
576-
retval= false;
577-
break;
578-
}
579-
elseif (sqlstate&&
580-
(strcmp(sqlstate,ERRCODE_LOCK_NOT_AVAILABLE)==0||
581-
strcmp(sqlstate,ERRCODE_INSUFFICIENT_PRIVILEGE)==0))
582-
{
583-
retval= true;
584-
break;
585-
}
586-
/* else, falls through */
587-
default:
588-
warn_or_exit_horribly(AH,"LOCK TABLE failed for \"%s\": %s",
589-
"pg_catalog.pg_class_tblspc_relfilenode_index",
590-
PQerrorMessage(AH->connection));
591-
retval= false;/* not reached */
592-
break;
593-
}
594-
PQclear(res);
595-
596-
CommitTransaction(AHX);
597-
598-
returnretval;
599-
}
600-
601535
void
602536
StartTransaction(Archive*AHX)
603537
{

‎src/bin/pg_dump/pg_backup_db.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ extern PGresult *ExecuteSqlQueryForSingleRow(Archive *fout, const char *query);
2020

2121
externvoidEndDBCopyMode(Archive*AHX,constchar*tocEntryTag);
2222

23-
externboolIsLockTableGeneric(Archive*AHX);
24-
2523
externvoidStartTransaction(Archive*AHX);
2624
externvoidCommitTransaction(Archive*AHX);
2725

‎src/bin/pg_dump/pg_dump.c‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,9 +1177,6 @@ setup_connection(Archive *AH, const char *dumpencoding,
11771177
ExecuteSqlStatement(AH, "SET row_security = off");
11781178
}
11791179

1180-
/* Detect whether LOCK TABLE can handle non-table relations */
1181-
AH->hasGenericLockTable = IsLockTableGeneric(AH);
1182-
11831180
/*
11841181
* Start transaction-snapshot mode transaction to dump consistent data.
11851182
*/
@@ -6843,16 +6840,16 @@ getTables(Archive *fout, int *numTables)
68436840
* assume our lock on the child is enough to prevent schema
68446841
* alterations to parent tables.
68456842
*
6846-
* We only need to lock the relation for certain components; see
6847-
* pg_dump.h
6843+
* NOTE: it'd be kinda nice to lock other relations too, not only
6844+
* plain or partitioned tables, but the backend doesn't presently
6845+
* allow that.
68486846
*
6849-
*On server versions that support it, we lock all relations not just
6850-
*plain tables.
6847+
*We only need to lock the table for certain components; see
6848+
*pg_dump.h
68516849
*/
68526850
if (tblinfo[i].dobj.dump &&
6853-
(fout->hasGenericLockTable ||
6854-
tblinfo[i].relkind == RELKIND_PARTITIONED_TABLE ||
6855-
tblinfo[i].relkind == RELKIND_RELATION) &&
6851+
(tblinfo[i].relkind == RELKIND_RELATION ||
6852+
tblinfo->relkind == RELKIND_PARTITIONED_TABLE) &&
68566853
(tblinfo[i].dobj.dump & DUMP_COMPONENTS_REQUIRING_LOCK))
68576854
{
68586855
resetPQExpBuffer(query);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp