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

Commitc9a6490

Browse files
committed
Clean up some leftover problems in pgstattuple: remove unwanted and
unportable elog(NOTICE) report, fix install/uninstall sequence.Itagaki Takahiro
1 parent57bfb27 commitc9a6490

File tree

4 files changed

+32
-93
lines changed

4 files changed

+32
-93
lines changed

‎contrib/pgstattuple/pgstatindex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ bt_page_items(PG_FUNCTION_ARGS)
561561
values[j]=palloc(32);
562562
snprintf(values[j++],32,"(%u,%u)",blkno,itup->t_tid.ip_posid);
563563
values[j]=palloc(32);
564-
snprintf(values[j++],32,"%d",IndexTupleSize(itup));
564+
snprintf(values[j++],32,"%d",(int)IndexTupleSize(itup));
565565
values[j]=palloc(32);
566566
snprintf(values[j++],32,"%c",IndexTupleHasNulls(itup) ?'t' :'f');
567567
values[j]=palloc(32);

‎contrib/pgstattuple/pgstattuple.c

Lines changed: 17 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.23 2006/07/11 17:26:58 momjian Exp $
2+
* $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.24 2006/09/04 02:03:04 tgl Exp $
33
*
44
* Copyright (c) 2001,2002Tatsuo Ishii
55
*
@@ -59,35 +59,19 @@ typedef struct pgstattuple_type
5959
uint64free_space;/* free/reusable space in bytes */
6060
}pgstattuple_type;
6161

62-
/*
63-
* struct pgstat_btree_type
64-
*/
65-
typedefstructpgstat_btree_type
66-
{
67-
pgstattuple_typebase;/* inherits pgstattuple_type */
68-
69-
uint64continuous;
70-
uint64forward;
71-
uint64backward;
72-
}pgstat_btree_type;
73-
7462
typedefvoid (*pgstat_page)(pgstattuple_type*,Relation,BlockNumber);
7563

7664
staticDatumbuild_pgstattuple_type(pgstattuple_type*stat,
7765
FunctionCallInfofcinfo);
7866
staticDatumpgstat_relation(Relationrel,FunctionCallInfofcinfo);
7967
staticDatumpgstat_heap(Relationrel,FunctionCallInfofcinfo);
80-
staticDatumpgstat_btree(Relationrel,FunctionCallInfofcinfo);
8168
staticvoidpgstat_btree_page(pgstattuple_type*stat,
8269
Relationrel,BlockNumberblkno);
83-
staticDatumpgstat_hash(Relationrel,FunctionCallInfofcinfo);
8470
staticvoidpgstat_hash_page(pgstattuple_type*stat,
8571
Relationrel,BlockNumberblkno);
86-
staticDatumpgstat_gist(Relationrel,FunctionCallInfofcinfo);
8772
staticvoidpgstat_gist_page(pgstattuple_type*stat,
8873
Relationrel,BlockNumberblkno);
89-
staticDatumpgstat_index(pgstattuple_type*stat,
90-
Relationrel,BlockNumberstart,
74+
staticDatumpgstat_index(Relationrel,BlockNumberstart,
9175
pgstat_pagepagefn,FunctionCallInfofcinfo);
9276
staticvoidpgstat_index_page(pgstattuple_type*stat,Pagepage,
9377
OffsetNumberminoff,OffsetNumbermaxoff);
@@ -217,11 +201,14 @@ pgstat_relation(Relation rel, FunctionCallInfo fcinfo)
217201
switch(rel->rd_rel->relam)
218202
{
219203
caseBTREE_AM_OID:
220-
returnpgstat_btree(rel,fcinfo);
204+
returnpgstat_index(rel,BTREE_METAPAGE+1,
205+
pgstat_btree_page,fcinfo);
221206
caseHASH_AM_OID:
222-
returnpgstat_hash(rel,fcinfo);
207+
returnpgstat_index(rel,HASH_METAPAGE+1,
208+
pgstat_hash_page,fcinfo);
223209
caseGIST_AM_OID:
224-
returnpgstat_gist(rel,fcinfo);
210+
returnpgstat_index(rel,GIST_ROOT_BLKNO+1,
211+
pgstat_gist_page,fcinfo);
225212
caseGIN_AM_OID:
226213
err="gin index";
227214
break;
@@ -321,36 +308,13 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
321308
}
322309

323310
/*
324-
* pgstat_btree -- returns live/dead tuples info in a btree index
325-
*/
326-
staticDatum
327-
pgstat_btree(Relationrel,FunctionCallInfofcinfo)
328-
{
329-
pgstat_btree_typestat= { {0 } };
330-
Datumdatum;
331-
332-
datum=pgstat_index((pgstattuple_type*)&stat,rel,
333-
BTREE_METAPAGE+1,pgstat_btree_page,fcinfo);
334-
335-
ereport(NOTICE,
336-
(errmsg("%.2f%% fragmented",
337-
100.0* (stat.forward+stat.backward) /
338-
(stat.continuous+stat.forward+stat.backward)),
339-
errhint("continuous=%llu, forward=%llu, backward=%llu",
340-
stat.continuous,stat.forward,stat.backward)));
341-
342-
returndatum;
343-
}
344-
345-
/*
346-
* pgstat_btree_page
311+
* pgstat_btree_page -- check tuples in a btree page
347312
*/
348313
staticvoid
349314
pgstat_btree_page(pgstattuple_type*stat,Relationrel,BlockNumberblkno)
350315
{
351316
Bufferbuf;
352317
Pagepage;
353-
pgstat_btree_type*btstat= (pgstat_btree_type*)stat;
354318

355319
buf=ReadBuffer(rel,blkno);
356320
LockBuffer(buf,BT_READ);
@@ -373,16 +337,6 @@ pgstat_btree_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno)
373337
}
374338
elseif (P_ISLEAF(opaque))
375339
{
376-
/* check fragmentation */
377-
if (P_RIGHTMOST(opaque))
378-
btstat->continuous++;
379-
elseif (opaque->btpo_next<blkno)
380-
btstat->backward++;
381-
elseif (opaque->btpo_next>blkno+1)
382-
btstat->forward++;
383-
else
384-
btstat->continuous++;
385-
386340
pgstat_index_page(stat,page,P_FIRSTDATAKEY(opaque),
387341
PageGetMaxOffsetNumber(page));
388342
}
@@ -396,17 +350,7 @@ pgstat_btree_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno)
396350
}
397351

398352
/*
399-
* pgstat_hash -- returns live/dead tuples info in a hash index
400-
*/
401-
staticDatum
402-
pgstat_hash(Relationrel,FunctionCallInfofcinfo)
403-
{
404-
pgstattuple_typestat= {0 };
405-
returnpgstat_index(&stat,rel,HASH_METAPAGE+1,pgstat_hash_page,fcinfo);
406-
}
407-
408-
/*
409-
* pgstat_hash_page
353+
* pgstat_hash_page -- check tuples in a hash page
410354
*/
411355
staticvoid
412356
pgstat_hash_page(pgstattuple_type*stat,Relationrel,BlockNumberblkno)
@@ -448,17 +392,7 @@ pgstat_hash_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno)
448392
}
449393

450394
/*
451-
* pgstat_gist -- returns live/dead tuples info in a gist index
452-
*/
453-
staticDatum
454-
pgstat_gist(Relationrel,FunctionCallInfofcinfo)
455-
{
456-
pgstattuple_typestat= {0 };
457-
returnpgstat_index(&stat,rel,GIST_ROOT_BLKNO+1,pgstat_gist_page,fcinfo);
458-
}
459-
460-
/*
461-
* pgstat_gist_page
395+
* pgstat_gist_page -- check tuples in a gist page
462396
*/
463397
staticvoid
464398
pgstat_gist_page(pgstattuple_type*stat,Relationrel,BlockNumberblkno)
@@ -488,11 +422,12 @@ pgstat_gist_page(pgstattuple_type *stat, Relation rel, BlockNumber blkno)
488422
* pgstat_index -- returns live/dead tuples info in a generic index
489423
*/
490424
staticDatum
491-
pgstat_index(pgstattuple_type*stat,Relationrel,BlockNumberstart,
492-
pgstat_pagepagefn,FunctionCallInfofcinfo)
425+
pgstat_index(Relationrel,BlockNumberstart,pgstat_pagepagefn,
426+
FunctionCallInfofcinfo)
493427
{
494428
BlockNumbernblocks;
495429
BlockNumberblkno;
430+
pgstattuple_typestat= {0 };
496431

497432
blkno=start;
498433
for (;;)
@@ -505,17 +440,17 @@ pgstat_index(pgstattuple_type *stat, Relation rel, BlockNumber start,
505440
/* Quit if we've scanned the whole relation */
506441
if (blkno >=nblocks)
507442
{
508-
stat->table_len= (uint64)nblocks*BLCKSZ;
443+
stat.table_len= (uint64)nblocks*BLCKSZ;
509444
break;
510445
}
511446

512447
for (;blkno<nblocks;blkno++)
513-
pagefn(stat,rel,blkno);
448+
pagefn(&stat,rel,blkno);
514449
}
515450

516451
relation_close(rel,AccessShareLock);
517452

518-
returnbuild_pgstattuple_type(stat,fcinfo);
453+
returnbuild_pgstattuple_type(&stat,fcinfo);
519454
}
520455

521456
/*

‎contrib/pgstattuple/pgstattuple.sql.in

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ LANGUAGE C STRICT;
2626
--
2727
-- pgstatindex
2828
--
29-
DROP TYPE pgstatindex_type CASCADE;
3029
CREATE TYPE pgstatindex_type AS (
3130
version int4,
3231
tree_level int4,
@@ -48,7 +47,6 @@ LANGUAGE 'C' STRICT;
4847
--
4948
-- bt_metap()
5049
--
51-
DROP TYPE bt_metap_type CASCADE;
5250
CREATE TYPE bt_metap_type AS (
5351
magic int4,
5452
version int4,
@@ -66,7 +64,6 @@ LANGUAGE 'C' STRICT;
6664
--
6765
-- bt_page_stats()
6866
--
69-
DROP TYPE bt_page_stats_type CASCADE;
7067
CREATE TYPE bt_page_stats_type AS (
7168
blkno int4,
7269
type char,
@@ -81,8 +78,6 @@ CREATE TYPE bt_page_stats_type AS (
8178
btpo_flags int4
8279
);
8380

84-
DROP FUNCTION bt_page_stats(text, int4);
85-
8681
CREATE OR REPLACE FUNCTION bt_page_stats(text, int4)
8782
RETURNS bt_page_stats_type
8883
AS 'MODULE_PATHNAME', 'bt_page_stats'
@@ -91,7 +86,6 @@ LANGUAGE 'C' STRICT;
9186
--
9287
-- bt_page_items()
9388
--
94-
DROP TYPE bt_page_items_type CASCADE;
9589
CREATE TYPE bt_page_items_type AS (
9690
itemoffset int4,
9791
ctid tid,
@@ -101,8 +95,6 @@ CREATE TYPE bt_page_items_type AS (
10195
data text
10296
);
10397

104-
DROP FUNCTION bt_page_items(text, int4);
105-
10698
CREATE OR REPLACE FUNCTION bt_page_items(text, int4)
10799
RETURNS SETOF bt_page_items_type
108100
AS 'MODULE_PATHNAME', 'bt_page_items'

‎contrib/pgstattuple/uninstall_pgstattuple.sql

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,19 @@
22
SET search_path= public;
33

44
DROPFUNCTION pgstattuple(oid);
5-
65
DROPFUNCTION pgstattuple(text);
7-
86
DROPTYPE pgstattuple_type;
7+
8+
DROPFUNCTION pgstatindex(text);
9+
DROPTYPE pgstatindex_type;
10+
11+
DROPFUNCTION bt_metap(text);
12+
DROPTYPE bt_metap_type;
13+
14+
DROPFUNCTION bt_page_stats(text, int4);
15+
DROPTYPE bt_page_stats_type;
16+
17+
DROPFUNCTION bt_page_items(text, int4);
18+
DROPTYPE bt_page_items_type;
19+
20+
DROPFUNCTION pg_relpages(text);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp