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

Commitbef5fcc

Browse files
committed
pgstatindex, pageinspect: handle partitioned indexes
Commit8b08f7d failed to update these modules to at least givenon-broken error messages for partitioned indexes. Add appropriateerror support to them.Peter G. was complaining about a problem of unfriendly error messages;while we haven't fixed that yet, subsequent discussion let to discoveryof these unhandled cases.Author: Michaël PaquierReported-by: Peter GeogheganDiscussion:https://postgr.es/m/CAH2-WzkOKptQiE51Bh4_xeEHhaBwHkZkGtKizrFMgEkfUuRRQg@mail.gmail.com
1 parentc8478f4 commitbef5fcc

File tree

7 files changed

+22
-3
lines changed

7 files changed

+22
-3
lines changed

‎contrib/pageinspect/expected/page.out

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,14 @@ SELECT * FROM fsm_page_contents(get_raw_page('test1', 'fsm', 0));
8383
(1 row)
8484

8585
DROP TABLE test1;
86-
-- check that using any of these functions with a partitioned table would fail
86+
-- check that using any of these functions with a partitioned table or index
87+
-- would fail
8788
create table test_partitioned (a int) partition by range (a);
89+
create index test_partitioned_index on test_partitioned (a);
8890
select get_raw_page('test_partitioned', 0); -- error about partitioned table
8991
ERROR: cannot get raw page from partitioned table "test_partitioned"
92+
select get_raw_page('test_partitioned_index', 0); -- error about partitioned index
93+
ERROR: cannot get raw page from partitioned index "test_partitioned_index"
9094
-- a regular table which is a member of a partition set should work though
9195
create table test_part1 partition of test_partitioned for values from ( 1 ) to (100);
9296
select get_raw_page('test_part1', 0); -- get farther and error about empty table

‎contrib/pageinspect/rawpage.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ get_raw_page_internal(text *relname, ForkNumber forknum, BlockNumber blkno)
128128
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
129129
errmsg("cannot get raw page from partitioned table \"%s\"",
130130
RelationGetRelationName(rel))));
131+
if (rel->rd_rel->relkind==RELKIND_PARTITIONED_INDEX)
132+
ereport(ERROR,
133+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
134+
errmsg("cannot get raw page from partitioned index \"%s\"",
135+
RelationGetRelationName(rel))));
131136

132137
/*
133138
* Reject attempts to read non-local temporary relations; we would be

‎contrib/pageinspect/sql/page.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@ SELECT * FROM fsm_page_contents(get_raw_page('test1', 'fsm', 0));
3333

3434
DROPTABLE test1;
3535

36-
-- check that using any of these functions with a partitioned table would fail
36+
-- check that using any of these functions with a partitioned table or index
37+
-- would fail
3738
createtabletest_partitioned (aint) partition by range (a);
39+
createindextest_partitioned_indexon test_partitioned (a);
3840
select get_raw_page('test_partitioned',0);-- error about partitioned table
41+
select get_raw_page('test_partitioned_index',0);-- error about partitioned index
3942

4043
-- a regular table which is a member of a partition set should work though
4144
createtabletest_part1 partition of test_partitioned forvaluesfrom (1 ) to (100);

‎contrib/pgstattuple/expected/pgstattuple.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,12 @@ select pgstatginindex('test_hashidx');
152152
ERROR: relation "test_hashidx" is not a GIN index
153153
-- check that using any of these functions with unsupported relations will fail
154154
create table test_partitioned (a int) partition by range (a);
155+
create index test_partitioned_index on test_partitioned(a);
155156
-- these should all fail
156157
select pgstattuple('test_partitioned');
157158
ERROR: "test_partitioned" (partitioned table) is not supported
159+
select pgstattuple('test_partitioned_index');
160+
ERROR: "test_partitioned_index" (partitioned index) is not supported
158161
select pgstattuple_approx('test_partitioned');
159162
ERROR: "test_partitioned" is not a table or materialized view
160163
select pg_relpages('test_partitioned');

‎contrib/pgstattuple/pgstatindex.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,6 @@ pgstathashindex(PG_FUNCTION_ARGS)
604604
errmsg("relation \"%s\" is not a hash index",
605605
RelationGetRelationName(rel))));
606606

607-
608607
/*
609608
* Reject attempts to read non-local temporary relations; we would be
610609
* likely to get wrong data since we have no visibility into the owning

‎contrib/pgstattuple/pgstattuple.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,9 @@ pgstat_relation(Relation rel, FunctionCallInfo fcinfo)
296296
caseRELKIND_PARTITIONED_TABLE:
297297
err="partitioned table";
298298
break;
299+
caseRELKIND_PARTITIONED_INDEX:
300+
err="partitioned index";
301+
break;
299302
default:
300303
err="unknown";
301304
break;

‎contrib/pgstattuple/sql/pgstattuple.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ select pgstatginindex('test_hashidx');
6464

6565
-- check that using any of these functions with unsupported relations will fail
6666
createtabletest_partitioned (aint) partition by range (a);
67+
createindextest_partitioned_indexon test_partitioned(a);
6768
-- these should all fail
6869
select pgstattuple('test_partitioned');
70+
select pgstattuple('test_partitioned_index');
6971
select pgstattuple_approx('test_partitioned');
7072
select pg_relpages('test_partitioned');
7173
select pgstatindex('test_partitioned');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp