aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-11-06 18:33:15 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2018-11-06 18:33:28 -0500
commit5d28c9bd73e29890cccd3f6b188b86f81031f671 (patch)
tree58a1788ce0b0d087e3268c03e86ae165bec51879 /src
parentc4f0876fb8d8f84fc0a6fb6aee91de120718664c (diff)
downloadpostgresql-5d28c9bd73e29890cccd3f6b188b86f81031f671.tar.gz
postgresql-5d28c9bd73e29890cccd3f6b188b86f81031f671.zip
Disable recheck_on_update optimization to avoid crashes.
The code added by commit c203d6cf8 causes a crash in at least one case, where a potentially-optimizable expression index has a storage type different from the input data type. A cursory code review turned up numerous other problems that seem impractical to fix on short notice. Andres argued for revert of that patch some time ago, and if additional senior committers had been paying attention, that's likely what would have happened, but we were not :-( At this point we can't just revert, at least not in v11, because that would mean an ABI break for code touching relcache entries. And we should not remove the (also buggy) support for the recheck_on_update index reloption, since it might already be used in some databases in the field. So this patch just does the as-little-invasive-as-possible measure of disabling the feature as though recheck_on_update were forced off for all indexes. I also removed the related regression tests (which would otherwise fail) and the user-facing documentation of the reloption. We should undertake a more thorough code cleanup if the patch can't be fixed, but not under the extreme time pressure of being already overdue for 11.1 release. Per report from Ondřej Bouda and subsequent private discussion among pgsql-release. Discussion: https://postgr.es/m/20181106185255.776mstcyehnc63ty@alvherre.pgsql
Diffstat (limited to 'src')
-rw-r--r--src/backend/utils/cache/relcache.c3
-rw-r--r--src/test/regress/expected/func_index.out64
-rw-r--r--src/test/regress/parallel_schedule2
-rw-r--r--src/test/regress/serial_schedule1
-rw-r--r--src/test/regress/sql/func_index.sql31
5 files changed, 4 insertions, 97 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index fd3d010b778..aecbd4a9437 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -4755,6 +4755,7 @@ IsProjectionFunctionalIndex(Relation index, IndexInfo *ii)
{
bool is_projection = false;
+#ifdef NOT_USED
if (ii->ii_Expressions)
{
HeapTuple tuple;
@@ -4800,6 +4801,8 @@ IsProjectionFunctionalIndex(Relation index, IndexInfo *ii)
}
ReleaseSysCache(tuple);
}
+#endif
+
return is_projection;
}
diff --git a/src/test/regress/expected/func_index.out b/src/test/regress/expected/func_index.out
deleted file mode 100644
index 307ac97b4bc..00000000000
--- a/src/test/regress/expected/func_index.out
+++ /dev/null
@@ -1,64 +0,0 @@
-begin;
-create table keyvalue(id integer primary key, info jsonb);
-create index nameindex on keyvalue((info->>'name')) with (recheck_on_update=false);
-insert into keyvalue values (1, '{"name": "john", "data": "some data"}');
-update keyvalue set info='{"name": "john", "data": "some other data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
- pg_stat_get_xact_tuples_hot_updated
--------------------------------------
- 0
-(1 row)
-
-rollback;
-begin;
-create table keyvalue(id integer primary key, info jsonb);
-create index nameindex on keyvalue((info->>'name')) with (recheck_on_update=true);
-insert into keyvalue values (1, '{"name": "john", "data": "some data"}');
-update keyvalue set info='{"name": "john", "data": "some other data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
- pg_stat_get_xact_tuples_hot_updated
--------------------------------------
- 1
-(1 row)
-
-update keyvalue set info='{"name": "smith", "data": "some other data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
- pg_stat_get_xact_tuples_hot_updated
--------------------------------------
- 1
-(1 row)
-
-update keyvalue set info='{"name": "smith", "data": "some more data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
- pg_stat_get_xact_tuples_hot_updated
--------------------------------------
- 2
-(1 row)
-
-rollback;
-begin;
-create table keyvalue(id integer primary key, info jsonb);
-create index nameindex on keyvalue((info->>'name'));
-insert into keyvalue values (1, '{"name": "john", "data": "some data"}');
-update keyvalue set info='{"name": "john", "data": "some other data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
- pg_stat_get_xact_tuples_hot_updated
--------------------------------------
- 1
-(1 row)
-
-update keyvalue set info='{"name": "smith", "data": "some other data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
- pg_stat_get_xact_tuples_hot_updated
--------------------------------------
- 1
-(1 row)
-
-update keyvalue set info='{"name": "smith", "data": "some more data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
- pg_stat_get_xact_tuples_hot_updated
--------------------------------------
- 2
-(1 row)
-
-rollback;
diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule
index b5e15501dd7..289c658483c 100644
--- a/src/test/regress/parallel_schedule
+++ b/src/test/regress/parallel_schedule
@@ -84,7 +84,7 @@ test: select_into select_distinct select_distinct_on select_implicit select_havi
# ----------
# Another group of parallel tests
# ----------
-test: brin gin gist spgist privileges init_privs security_label collate matview lock replica_identity rowsecurity object_address tablesample groupingsets drop_operator password func_index
+test: brin gin gist spgist privileges init_privs security_label collate matview lock replica_identity rowsecurity object_address tablesample groupingsets drop_operator password
# ----------
# Another group of parallel tests
diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule
index 49329ffbb62..bc43b18c628 100644
--- a/src/test/regress/serial_schedule
+++ b/src/test/regress/serial_schedule
@@ -99,7 +99,6 @@ test: portals
test: arrays
test: btree_index
test: hash_index
-test: func_index
test: update
test: delete
test: namespace
diff --git a/src/test/regress/sql/func_index.sql b/src/test/regress/sql/func_index.sql
deleted file mode 100644
index c267c93eb08..00000000000
--- a/src/test/regress/sql/func_index.sql
+++ /dev/null
@@ -1,31 +0,0 @@
-begin;
-create table keyvalue(id integer primary key, info jsonb);
-create index nameindex on keyvalue((info->>'name')) with (recheck_on_update=false);
-insert into keyvalue values (1, '{"name": "john", "data": "some data"}');
-update keyvalue set info='{"name": "john", "data": "some other data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
-rollback;
-
-begin;
-create table keyvalue(id integer primary key, info jsonb);
-create index nameindex on keyvalue((info->>'name')) with (recheck_on_update=true);
-insert into keyvalue values (1, '{"name": "john", "data": "some data"}');
-update keyvalue set info='{"name": "john", "data": "some other data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
-update keyvalue set info='{"name": "smith", "data": "some other data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
-update keyvalue set info='{"name": "smith", "data": "some more data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
-rollback;
-
-begin;
-create table keyvalue(id integer primary key, info jsonb);
-create index nameindex on keyvalue((info->>'name'));
-insert into keyvalue values (1, '{"name": "john", "data": "some data"}');
-update keyvalue set info='{"name": "john", "data": "some other data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
-update keyvalue set info='{"name": "smith", "data": "some other data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
-update keyvalue set info='{"name": "smith", "data": "some more data"}' where id=1;
-select pg_stat_get_xact_tuples_hot_updated('keyvalue'::regclass);
-rollback;