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

Commit45ffeb7

Browse files
committed
pageinspect: Use new pg_lsn datatype.
Michael Paquier, with slight comment changes by me
1 parentae95f5f commit45ffeb7

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

‎contrib/pageinspect/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ MODULE_big= pageinspect
44
OBJS= rawpage.o heapfuncs.o btreefuncs.o fsmfuncs.o
55

66
EXTENSION = pageinspect
7-
DATA = pageinspect--1.1.sql pageinspect--1.0--1.1.sql\
8-
pageinspect--unpackaged--1.0.sql
7+
DATA = pageinspect--1.2.sql pageinspect--1.0--1.1.sql\
8+
pageinspect--1.1--1.2.sql pageinspect--unpackaged--1.0.sql
99

1010
ifdefUSE_PGXS
1111
PG_CONFIG = pg_config
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* contrib/pageinspect/pageinspect--1.1--1.2.sql*/
2+
3+
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
4+
\echo Use"ALTER EXTENSION pageinspect UPDATE TO 1.2" to load this file. \quit
5+
6+
DROPFUNCTION page_header(bytea);
7+
CREATEFUNCTIONpage_header(IN pagebytea,
8+
OUT lsn pg_lsn,
9+
OUT checksumsmallint,
10+
OUT flagssmallint,
11+
OUTlowersmallint,
12+
OUTuppersmallint,
13+
OUT specialsmallint,
14+
OUT pagesizesmallint,
15+
OUT versionsmallint,
16+
OUT prune_xid xid)
17+
AS'MODULE_PATHNAME','page_header'
18+
LANGUAGE C STRICT;

‎contrib/pageinspect/pageinspect--1.1.sqlrenamed to‎contrib/pageinspect/pageinspect--1.2.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* contrib/pageinspect/pageinspect--1.1.sql*/
1+
/* contrib/pageinspect/pageinspect--1.2.sql*/
22

33
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
44
\echo Use"CREATE EXTENSION pageinspect" to load this file. \quit
@@ -20,7 +20,7 @@ LANGUAGE C STRICT;
2020
-- page_header()
2121
--
2222
CREATEFUNCTIONpage_header(IN pagebytea,
23-
OUT lsntext,
23+
OUT lsnpg_lsn,
2424
OUT checksumsmallint,
2525
OUT flagssmallint,
2626
OUTlowersmallint,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pageinspect extension
22
comment = 'inspect the contents of database pages at a low level'
3-
default_version = '1.1'
3+
default_version = '1.2'
44
module_pathname = '$libdir/pageinspect'
55
relocatable = true

‎contrib/pageinspect/rawpage.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
#include"access/htup_details.h"
1919
#include"catalog/catalog.h"
2020
#include"catalog/namespace.h"
21+
#include"catalog/pg_type.h"
2122
#include"funcapi.h"
2223
#include"miscadmin.h"
2324
#include"storage/bufmgr.h"
2425
#include"utils/builtins.h"
26+
#include"utils/pg_lsn.h"
2527
#include"utils/rel.h"
2628

2729
PG_MODULE_MAGIC;
@@ -180,7 +182,6 @@ page_header(PG_FUNCTION_ARGS)
180182

181183
PageHeaderpage;
182184
XLogRecPtrlsn;
183-
charlsnchar[64];
184185

185186
if (!superuser())
186187
ereport(ERROR,
@@ -207,10 +208,17 @@ page_header(PG_FUNCTION_ARGS)
207208
/* Extract information from the page header */
208209

209210
lsn=PageGetLSN(page);
210-
snprintf(lsnchar,sizeof(lsnchar),"%X/%X",
211-
(uint32) (lsn >>32), (uint32)lsn);
212211

213-
values[0]=CStringGetTextDatum(lsnchar);
212+
/* pageinspect >= 1.2 uses pg_lsn instead of text for the LSN field. */
213+
if (tupdesc->attrs[0]->atttypid==TEXTOID)
214+
{
215+
charlsnchar[64];
216+
snprintf(lsnchar,sizeof(lsnchar),"%X/%X",
217+
(uint32) (lsn >>32), (uint32)lsn);
218+
values[0]=CStringGetTextDatum(lsnchar);
219+
}
220+
else
221+
values[0]=LSNGetDatum(lsn);
214222
values[1]=UInt16GetDatum(page->pd_checksum);
215223
values[2]=UInt16GetDatum(page->pd_flags);
216224
values[3]=UInt16GetDatum(page->pd_lower);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp