PostgreSQL Source Code: contrib/pageinspect/gistfuncs.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
11
15#include "catalog/pg_am_d.h"
26
30
31#define IS_GIST(r) ((r)->rd_rel->relam == GIST_AM_OID)
32
33
35
36
37
38
39
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}
69
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}
128
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}
192
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}
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
static Datum values[MAXATTR]
static uint16 PageGetSpecialSize(const PageData *page)
static Item PageGetItem(const PageData *page, const ItemIdData *itemId)
static bool PageIsNew(const PageData *page)
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
static XLogRecPtr PageGetLSN(const PageData *page)
static OffsetNumber PageGetMaxOffsetNumber(const PageData *page)
#define CStringGetTextDatum(s)
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
char * OidOutputFunctionCall(Oid functionId, Datum val)
Datum Int64GetDatum(int64 X)
#define DirectFunctionCall1(func, arg1)
#define PG_GETARG_BYTEA_P(n)
void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
static Datum HeapTupleGetDatum(const HeapTupleData *tuple)
#define GistPageIsDeleted(page)
#define GistPageGetOpaque(page)
#define GistPageGetNSN(page)
PG_FUNCTION_INFO_V1(gist_page_opaque_info)
Datum gist_page_items_bytea(PG_FUNCTION_ARGS)
static Page verify_gist_page(bytea *raw_page)
Datum gist_page_items(PG_FUNCTION_ARGS)
Datum gist_page_opaque_info(PG_FUNCTION_ARGS)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
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
Page get_page_from_raw(bytea *raw_page)
static Datum LSNGetDatum(XLogRecPtr X)
static Datum PointerGetDatum(const void *X)
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)
#define SET_VARSIZE(PTR, len)
Datum to_hex32(PG_FUNCTION_ARGS)