ALTER TABLE set reloptions
Started by Simon Riggsalmost 12 years ago1 messages
As part of the ALTER TABLE lock reductions we've now agreed that
reloptions should have a lock level associated with them, so we can
take appropriate lock levels.
Attached patch will be applied at start of 9.5 dev cycle, so that any
new relopt authors are aware that lock levels are needed for any new
work.
Later patch will then use this infrastructure to (attempt) to reduce
lock levels, assuming no problems.
Added to next CF for June 2014, not for commit yet.
--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
Attachments:
relopt.patchapplication/octet-stream; name=relopt.patchDownload
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index 530a1ae..41de62a 100644
--- a/src/backend/access/common/reloptions.c
+++ b/src/backend/access/common/reloptions.c
@@ -57,6 +57,7 @@ static relopt_bool boolRelOpts[] =
{
"autovacuum_enabled",
"Enables autovacuum in this relation",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
},
true
@@ -65,6 +66,7 @@ static relopt_bool boolRelOpts[] =
{
"user_catalog_table",
"Declare a table as an additional catalog table, e.g. for the purpose of logical replication",
+ AccessExclusiveLock,
RELOPT_KIND_HEAP
},
false
@@ -73,6 +75,7 @@ static relopt_bool boolRelOpts[] =
{
"fastupdate",
"Enables \"fast update\" feature for this GIN index",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_GIN
},
true
@@ -81,6 +84,7 @@ static relopt_bool boolRelOpts[] =
{
"security_barrier",
"View acts as a row security barrier",
+ AccessExclusiveLock,
RELOPT_KIND_VIEW
},
false
@@ -95,6 +99,7 @@ static relopt_int intRelOpts[] =
{
"fillfactor",
"Packs table pages only to this percentage",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP
},
HEAP_DEFAULT_FILLFACTOR, HEAP_MIN_FILLFACTOR, 100
@@ -103,6 +108,7 @@ static relopt_int intRelOpts[] =
{
"fillfactor",
"Packs btree index pages only to this percentage",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_BTREE
},
BTREE_DEFAULT_FILLFACTOR, BTREE_MIN_FILLFACTOR, 100
@@ -111,6 +117,7 @@ static relopt_int intRelOpts[] =
{
"fillfactor",
"Packs hash index pages only to this percentage",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HASH
},
HASH_DEFAULT_FILLFACTOR, HASH_MIN_FILLFACTOR, 100
@@ -119,6 +126,7 @@ static relopt_int intRelOpts[] =
{
"fillfactor",
"Packs gist index pages only to this percentage",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_GIST
},
GIST_DEFAULT_FILLFACTOR, GIST_MIN_FILLFACTOR, 100
@@ -127,6 +135,7 @@ static relopt_int intRelOpts[] =
{
"fillfactor",
"Packs spgist index pages only to this percentage",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_SPGIST
},
SPGIST_DEFAULT_FILLFACTOR, SPGIST_MIN_FILLFACTOR, 100
@@ -135,6 +144,7 @@ static relopt_int intRelOpts[] =
{
"autovacuum_vacuum_threshold",
"Minimum number of tuple updates or deletes prior to vacuum",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
},
-1, 0, INT_MAX
@@ -143,6 +153,7 @@ static relopt_int intRelOpts[] =
{
"autovacuum_analyze_threshold",
"Minimum number of tuple inserts, updates or deletes prior to analyze",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP
},
-1, 0, INT_MAX
@@ -151,6 +162,7 @@ static relopt_int intRelOpts[] =
{
"autovacuum_vacuum_cost_delay",
"Vacuum cost delay in milliseconds, for autovacuum",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
},
-1, 0, 100
@@ -159,6 +171,7 @@ static relopt_int intRelOpts[] =
{
"autovacuum_vacuum_cost_limit",
"Vacuum cost amount available before napping, for autovacuum",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
},
-1, 1, 10000
@@ -167,6 +180,7 @@ static relopt_int intRelOpts[] =
{
"autovacuum_freeze_min_age",
"Minimum age at which VACUUM should freeze a table row, for autovacuum",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
},
-1, 0, 1000000000
@@ -175,6 +189,7 @@ static relopt_int intRelOpts[] =
{
"autovacuum_multixact_freeze_min_age",
"Minimum multixact age at which VACUUM should freeze a row multixact's, for autovacuum",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
},
-1, 0, 1000000000
@@ -183,6 +198,7 @@ static relopt_int intRelOpts[] =
{
"autovacuum_freeze_max_age",
"Age at which to autovacuum a table to prevent transaction ID wraparound",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
},
-1, 100000000, 2000000000
@@ -191,6 +207,7 @@ static relopt_int intRelOpts[] =
{
"autovacuum_multixact_freeze_max_age",
"Multixact age at which to autovacuum a table to prevent multixact wraparound",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
},
-1, 100000000, 2000000000
@@ -199,6 +216,7 @@ static relopt_int intRelOpts[] =
{
"autovacuum_freeze_table_age",
"Age at which VACUUM should perform a full table sweep to freeze row versions",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
}, -1, 0, 2000000000
},
@@ -206,6 +224,7 @@ static relopt_int intRelOpts[] =
{
"autovacuum_multixact_freeze_table_age",
"Age of multixact at which VACUUM should perform a full table sweep to freeze row versions",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
}, -1, 0, 2000000000
},
@@ -220,6 +239,7 @@ static relopt_real realRelOpts[] =
{
"autovacuum_vacuum_scale_factor",
"Number of tuple updates or deletes prior to vacuum as a fraction of reltuples",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP | RELOPT_KIND_TOAST
},
-1, 0.0, 100.0
@@ -228,6 +248,7 @@ static relopt_real realRelOpts[] =
{
"autovacuum_analyze_scale_factor",
"Number of tuple inserts, updates or deletes prior to analyze as a fraction of reltuples",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_HEAP
},
-1, 0.0, 100.0
@@ -236,6 +257,7 @@ static relopt_real realRelOpts[] =
{
"seq_page_cost",
"Sets the planner's estimate of the cost of a sequentially fetched disk page.",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_TABLESPACE
},
-1, 0.0, DBL_MAX
@@ -244,6 +266,7 @@ static relopt_real realRelOpts[] =
{
"random_page_cost",
"Sets the planner's estimate of the cost of a nonsequentially fetched disk page.",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_TABLESPACE
},
-1, 0.0, DBL_MAX
@@ -252,6 +275,7 @@ static relopt_real realRelOpts[] =
{
"n_distinct",
"Sets the planner's estimate of the number of distinct values appearing in a column (excluding child relations).",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_ATTRIBUTE
},
0, -1.0, DBL_MAX
@@ -260,6 +284,7 @@ static relopt_real realRelOpts[] =
{
"n_distinct_inherited",
"Sets the planner's estimate of the number of distinct values appearing in a column (including child relations).",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_ATTRIBUTE
},
0, -1.0, DBL_MAX
@@ -274,6 +299,7 @@ static relopt_string stringRelOpts[] =
{
"buffering",
"Enables buffering build for this GiST index",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_GIST
},
4,
@@ -285,6 +311,7 @@ static relopt_string stringRelOpts[] =
{
"check_option",
"View has WITH CHECK OPTION defined (local or cascaded).",
+ ShareUpdateExclusiveLock,
RELOPT_KIND_VIEW
},
0,
diff --git a/src/include/access/reloptions.h b/src/include/access/reloptions.h
index a54d563..5c0eff3 100644
--- a/src/include/access/reloptions.h
+++ b/src/include/access/reloptions.h
@@ -22,6 +22,7 @@
#include "access/htup.h"
#include "access/tupdesc.h"
#include "nodes/pg_list.h"
+#include "storage/lock.h"
/* types supported by reloptions */
typedef enum relopt_type
@@ -60,6 +61,7 @@ typedef struct relopt_gen
const char *name; /* must be first (used as list termination
* marker) */
const char *desc;
+ LOCKMODE lockmode;
bits32 kinds;
int namelen;
relopt_type type;