/* verify the special space has the expected size */ if (PageGetSpecialSize(page) != MAXALIGN(sizeof(GISTPageOpaqueData)))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "GiST"),
errdetail("Expected special size %d, got %d.",
(int) MAXALIGN(sizeof(GISTPageOpaqueData)),
(int) PageGetSpecialSize(page))));
opaq = GistPageGetOpaque(page); if (opaq->gist_page_id != GIST_PAGE_ID)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("input page is not a valid %s page", "GiST"),
errdetail("Expected %08x, got %08x.",
GIST_PAGE_ID,
opaq->gist_page_id)));
return page;
}
Datum
gist_page_opaque_info(PG_FUNCTION_ARGS)
{
bytea *raw_page = PG_GETARG_BYTEA_P(0);
TupleDesc tupdesc;
Page page;
HeapTuple resultTuple;
Datum values[4]; bool nulls[4];
Datum flags[16]; int nflags = 0;
uint16 flagbits;
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to use raw page functions")));
page = verify_gist_page(raw_page);
if (PageIsNew(page))
PG_RETURN_NULL();
/* Build a tuple descriptor for our result type */ if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
elog(ERROR, "return type must be a row type");
/* Convert the flags bitmask to an array of human-readable names */
flagbits = GistPageGetOpaque(page)->flags; if (flagbits & F_LEAF)
flags[nflags++] = CStringGetTextDatum("leaf"); if (flagbits & F_DELETED)
flags[nflags++] = CStringGetTextDatum("deleted"); if (flagbits & F_TUPLES_DELETED)
flags[nflags++] = CStringGetTextDatum("tuples_deleted"); if (flagbits & F_FOLLOW_RIGHT)
flags[nflags++] = CStringGetTextDatum("follow_right"); if (flagbits & F_HAS_GARBAGE)
flags[nflags++] = CStringGetTextDatum("has_garbage");
flagbits &= ~(F_LEAF | F_DELETED | F_TUPLES_DELETED | F_FOLLOW_RIGHT | F_HAS_GARBAGE); if (flagbits)
{ /* any flags we don't recognize are printed in hex */
flags[nflags++] = DirectFunctionCall1(to_hex32, Int32GetDatum(flagbits));
}
if (!superuser())
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to use raw page functions")));
InitMaterializedSRF(fcinfo, 0);
/* Open the relation */
indexRel = index_open(indexRelid, AccessShareLock);
if (!IS_GIST(indexRel))
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a %s index",
RelationGetRelationName(indexRel), "GiST")));
page = verify_gist_page(raw_page);
if (PageIsNew(page))
{
index_close(indexRel, AccessShareLock);
PG_RETURN_NULL();
}
if (i == IndexRelationGetNumberOfKeyAttributes(indexRel))
appendStringInfoString(&buf, ") INCLUDE ("); elseif (i > 0)
appendStringInfoString(&buf, ", ");
/* Check whether we need double quotes for this value */
nq = (value[0] == '\0'); /* force quotes for empty string */ for (tmp = value; *tmp; tmp++)
{ char ch = *tmp;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.