PostgreSQL Source Code: contrib/pageinspect/gistfuncs.c File Reference (original) (raw)
#include "[postgres.h](postgres%5F8h%5Fsource.html)"
#include "[access/gist.h](gist%5F8h%5Fsource.html)"
#include "[access/htup.h](htup%5F8h%5Fsource.html)"
#include "[access/relation.h](relation%5F8h%5Fsource.html)"
#include "catalog/pg_am_d.h"
#include "[funcapi.h](funcapi%5F8h%5Fsource.html)"
#include "[miscadmin.h](miscadmin%5F8h%5Fsource.html)"
#include "[pageinspect.h](pageinspect%5F8h%5Fsource.html)"
#include "[storage/itemptr.h](itemptr%5F8h%5Fsource.html)"
#include "[utils/array.h](array%5F8h%5Fsource.html)"
#include "[utils/builtins.h](builtins%5F8h%5Fsource.html)"
#include "[utils/lsyscache.h](lsyscache%5F8h%5Fsource.html)"
#include "[utils/pg_lsn.h](pg%5F%5Flsn%5F8h%5Fsource.html)"
#include "[utils/rel.h](rel%5F8h%5Fsource.html)"
#include "[utils/ruleutils.h](ruleutils%5F8h%5Fsource.html)"
Go to the source code of this file.
Macros | |
---|---|
#define | IS_GIST(r) ((r)->rd_rel->relam == GIST_AM_OID) |
◆ IS_GIST
| #define IS_GIST | ( | | r | ) | ((r)->rd_rel->relam == GIST_AM_OID) | | ---------------- | - | | - | - | -------------------------------------- |
◆ gist_page_items()
Definition at line 194 of file gistfuncs.c.
195{
203 bits16 printflags = 0;
206 char *index_columns;
207
210 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
211 errmsg("must be superuser to use raw page functions")));
212
214
215
217
220 (errcode(ERRCODE_WRONG_OBJECT_TYPE),
221 errmsg("\"%s\" is not a %s index",
223
225
227 {
230 }
231
233
234
235
236
237
239 if (flagbits & F_LEAF)
240 {
242 }
243 else
244 {
248 }
249
251 printflags);
252
253
256 else
258
260 offset <= maxoff;
261 offset++)
262 {
264 bool nulls[5];
270 int i;
271
273
276
278
280 itup_values, itup_isnull);
281
282 memset(nulls, 0, sizeof(nulls));
283
288
289 if (index_columns)
290 {
293
294
295 for (i = 0; i < tupdesc->natts; i++)
296 {
298 char *tmp;
299 bool nq = false;
300
301 if (itup_isnull[i])
303 else
304 {
305 Oid foutoid;
306 bool typisvarlena;
307 Oid typoid;
308
312 }
313
316 else if (i > 0)
318
319
320 nq = (value[0] == '\0');
321 for (tmp = value; *tmp; tmp++)
322 {
323 char ch = *tmp;
324
325 if (ch == '"' || ch == '\\' ||
326 ch == '(' || ch == ')' || ch == ',' ||
327 isspace((unsigned char) ch))
328 {
329 nq = true;
330 break;
331 }
332 }
333
334
335 if (nq)
337 for (tmp = value; *tmp; tmp++)
338 {
339 char ch = *tmp;
340
341 if (ch == '"' || ch == '\\')
344 }
345 if (nq)
347 }
348
350
352 nulls[4] = false;
353 }
354 else
355 {
357 nulls[4] = true;
358 }
359
361 }
362
364
365 return (Datum) 0;
366}
static Datum values[MAXATTR]
static Item PageGetItem(const PageData *page, const ItemIdData *itemId)
static bool PageIsNew(const PageData *page)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static OffsetNumber PageGetMaxOffsetNumber(const PageData *page)
#define CStringGetTextDatum(s)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
char * OidOutputFunctionCall(Oid functionId, Datum val)
#define PG_GETARG_BYTEA_P(n)
void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
#define GistPageIsDeleted(page)
#define GistPageGetOpaque(page)
static Page verify_gist_page(bytea *raw_page)
void index_close(Relation relation, LOCKMODE lockmode)
Relation index_open(Oid relationId, LOCKMODE lockmode)
void index_deform_tuple(IndexTuple tup, TupleDesc tupleDescriptor, Datum *values, bool *isnull)
if(TABLE==NULL||TABLE_index==NULL)
#define ItemIdIsDead(itemId)
#define ItemIdIsValid(itemId)
static Datum ItemPointerGetDatum(const ItemPointerData *X)
IndexTupleData * IndexTuple
static Size IndexTupleSize(const IndexTupleData *itup)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
#define InvalidOffsetNumber
#define FirstOffsetNumber
static Datum BoolGetDatum(bool X)
static Datum Int32GetDatum(int32 X)
static int16 DatumGetInt16(Datum X)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define IndexRelationGetNumberOfKeyAttributes(relation)
char * pg_get_indexdef_columns_extended(Oid indexrelid, bits16 flags)
#define RULE_INDEXDEF_PRETTY
#define RULE_INDEXDEF_KEYS_ONLY
void relation_close(Relation relation, LOCKMODE lockmode)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
#define appendStringInfoCharMacro(str, ch)
Tuplestorestate * setResult
TupleDesc CreateTupleDescTruncatedCopy(TupleDesc tupdesc, int natts)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
void tuplestore_putvalues(Tuplestorestate *state, TupleDesc tdesc, const Datum *values, const bool *isnull)
References AccessShareLock, appendStringInfo(), appendStringInfoChar(), appendStringInfoCharMacro, appendStringInfoString(), BoolGetDatum(), buf, CreateTupleDescTruncatedCopy(), CStringGetTextDatum, DatumGetInt16(), elog, ereport, errcode(), errmsg(), ERROR, F_LEAF, FirstOffsetNumber, getTypeOutputInfo(), GistPageGetOpaque, GistPageIsDeleted, i, if(), index_close(), index_deform_tuple(), INDEX_MAX_KEYS, index_open(), IndexRelationGetNumberOfKeyAttributes, IndexTupleSize(), InitMaterializedSRF(), initStringInfo(), Int32GetDatum(), InvalidOffsetNumber, IS_GIST, ItemIdIsDead, ItemIdIsValid, ItemPointerGetDatum(), NOTICE, OidOutputFunctionCall(), PageGetItem(), PageGetItemId(), PageGetMaxOffsetNumber(), PageIsNew(), pg_get_indexdef_columns_extended(), PG_GETARG_BYTEA_P, PG_GETARG_OID, PG_RETURN_NULL, relation_close(), RelationGetDescr, RelationGetRelationName, RULE_INDEXDEF_KEYS_ONLY, RULE_INDEXDEF_PRETTY, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, superuser(), IndexTupleData::t_tid, TupleDescAttr(), tuplestore_putvalues(), value, values, and verify_gist_page().
◆ gist_page_items_bytea()
Definition at line 130 of file gistfuncs.c.
131{
137
140 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
141 errmsg("must be superuser to use raw page functions")));
142
144
146
149
150
153 else
155
157 offset <= maxoff;
158 offset++)
159 {
161 bool nulls[5];
164 bytea *tuple_bytea;
165 int tuple_len;
166
168
171
174
175 memset(nulls, 0, sizeof(nulls));
176
180
183 memcpy(VARDATA(tuple_bytea), itup, tuple_len);
186
188 }
189
190 return (Datum) 0;
191}
static Datum PointerGetDatum(const void *X)
#define SET_VARSIZE(PTR, len)
References BoolGetDatum(), DatumGetInt16(), elog, ereport, errcode(), errmsg(), ERROR, FirstOffsetNumber, GistPageIsDeleted, if(), IndexTupleSize(), InitMaterializedSRF(), Int32GetDatum(), InvalidOffsetNumber, ItemIdIsDead, ItemIdIsValid, ItemPointerGetDatum(), NOTICE, PageGetItem(), PageGetItemId(), PageGetMaxOffsetNumber(), PageIsNew(), palloc(), PG_GETARG_BYTEA_P, PG_RETURN_NULL, PointerGetDatum(), SET_VARSIZE, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, superuser(), IndexTupleData::t_tid, tuplestore_putvalues(), values, VARDATA, VARHDRSZ, and verify_gist_page().
◆ gist_page_opaque_info()
Definition at line 71 of file gistfuncs.c.
72{
78 bool nulls[4];
80 int nflags = 0;
82
85 (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
86 errmsg("must be superuser to use raw page functions")));
87
89
92
93
95 elog(ERROR, "return type must be a row type");
96
97
99 if (flagbits & F_LEAF)
110 if (flagbits)
111 {
112
114 }
115
116 memset(nulls, 0, sizeof(nulls));
117
122
123
125
127}
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
static XLogRecPtr PageGetLSN(const PageData *page)
Datum Int64GetDatum(int64 X)
#define DirectFunctionCall1(func, arg1)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
#define GistPageGetNSN(page)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
static Datum LSNGetDatum(XLogRecPtr X)
Datum to_hex32(PG_FUNCTION_ARGS)
References construct_array_builtin(), CStringGetTextDatum, DirectFunctionCall1, elog, ereport, errcode(), errmsg(), ERROR, F_DELETED, F_FOLLOW_RIGHT, F_HAS_GARBAGE, F_LEAF, F_TUPLES_DELETED, get_call_result_type(), GistPageGetNSN, GistPageGetOpaque, heap_form_tuple(), HeapTupleGetDatum(), Int32GetDatum(), Int64GetDatum(), LSNGetDatum(), PageGetLSN(), PageIsNew(), PG_GETARG_BYTEA_P, PG_RETURN_NULL, PointerGetDatum(), superuser(), to_hex32(), TYPEFUNC_COMPOSITE, values, and verify_gist_page().
◆ PG_FUNCTION_INFO_V1() [1/3]
◆ PG_FUNCTION_INFO_V1() [2/3]
◆ PG_FUNCTION_INFO_V1() [3/3]
◆ verify_gist_page()
static Page verify_gist_page ( bytea * raw_page) | static |
---|
Definition at line 41 of file gistfuncs.c.
42{
45
47 return page;
48
49
52 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
53 errmsg("input page is not a valid %s page", "GiST"),
54 errdetail("Expected special size %d, got %d.",
57
61 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
62 errmsg("input page is not a valid %s page", "GiST"),
63 errdetail("Expected %08x, got %08x.",
66
67 return page;
68}
static uint16 PageGetSpecialSize(const PageData *page)
int errdetail(const char *fmt,...)
Page get_page_from_raw(bytea *raw_page)
References ereport, errcode(), errdetail(), errmsg(), ERROR, get_page_from_raw(), GISTPageOpaqueData::gist_page_id, GIST_PAGE_ID, GistPageGetOpaque, MAXALIGN, PageGetSpecialSize(), and PageIsNew().
Referenced by gist_page_items(), gist_page_items_bytea(), and gist_page_opaque_info().