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

Commitd3adaab

Browse files
committed
Revert "pg_dump: Lock all relations, not just plain tables".
Revert403a3d9, as well as the followup fix7f42350, 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 parent53f614f commitd3adaab

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
@@ -199,8 +199,6 @@ typedef struct Archive
199199
intminRemoteVersion;/* allowable range */
200200
intmaxRemoteVersion;
201201

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

‎src/bin/pg_dump/pg_backup_db.c

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

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

‎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
@@ -1185,9 +1185,6 @@ setup_connection(Archive *AH, const char *dumpencoding,
11851185
ExecuteSqlStatement(AH, "SET row_security = off");
11861186
}
11871187

1188-
/* Detect whether LOCK TABLE can handle non-table relations */
1189-
AH->hasGenericLockTable = IsLockTableGeneric(AH);
1190-
11911188
/*
11921189
* Start transaction-snapshot mode transaction to dump consistent data.
11931190
*/
@@ -6855,16 +6852,16 @@ getTables(Archive *fout, int *numTables)
68556852
* assume our lock on the child is enough to prevent schema
68566853
* alterations to parent tables.
68576854
*
6858-
* We only need to lock the relation for certain components; see
6859-
* pg_dump.h
6855+
* NOTE: it'd be kinda nice to lock other relations too, not only
6856+
* plain or partitioned tables, but the backend doesn't presently
6857+
* allow that.
68606858
*
6861-
*On server versions that support it, we lock all relations not just
6862-
*plain tables.
6859+
*We only need to lock the table for certain components; see
6860+
*pg_dump.h
68636861
*/
68646862
if (tblinfo[i].dobj.dump &&
6865-
(fout->hasGenericLockTable ||
6866-
tblinfo[i].relkind == RELKIND_PARTITIONED_TABLE ||
6867-
tblinfo[i].relkind == RELKIND_RELATION) &&
6863+
(tblinfo[i].relkind == RELKIND_RELATION ||
6864+
tblinfo->relkind == RELKIND_PARTITIONED_TABLE) &&
68686865
(tblinfo[i].dobj.dump & DUMP_COMPONENTS_REQUIRING_LOCK))
68696866
{
68706867
resetPQExpBuffer(query);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp