mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
Use wrappers of PG_DETOAST_DATUM_PACKED() more.
This makes almost all core code follow the policy introduced in the previous commit. Specific decisions: - Text search support functions with char* and length arguments, such as prsstart and lexize, may receive unaligned strings. I doubt maintainers of non-core text search code will notice. - Use plain VARDATA() on values detoasted or synthesized earlier in the same function. Use VARDATA_ANY() on varlenas sourced outside the function, even if they happen to always have four-byte headers. As an exception, retain the universal practice of using VARDATA() on return values of SendFunctionCall(). - Retain PG_GETARG_BYTEA_P() in pageinspect. (Page images are too large for a one-byte header, so this misses no optimization.) Sites that do not call get_page_from_raw() typically need the four-byte alignment. - For now, do not change btree_gist. Its use of four-byte headers in memory is partly entangled with storage of 4-byte headers inside GBT_VARKEY, on disk. - For now, do not change gtrgm_consistent() or gtrgm_distance(). They incorporate the varlena header into a cache, and there are multiple credible implementation strategies to consider.
This commit is contained in:
@ -123,7 +123,7 @@ ts_token_type_byname(PG_FUNCTION_ARGS)
|
||||
|
||||
if (SRF_IS_FIRSTCALL())
|
||||
{
|
||||
text *prsname = PG_GETARG_TEXT_P(0);
|
||||
text *prsname = PG_GETARG_TEXT_PP(0);
|
||||
Oid prsId;
|
||||
|
||||
funcctx = SRF_FIRSTCALL_INIT();
|
||||
@ -172,8 +172,8 @@ prs_setup_firstcall(FuncCallContext *funcctx, Oid prsid, text *txt)
|
||||
st->list = (LexemeEntry *) palloc(sizeof(LexemeEntry) * st->len);
|
||||
|
||||
prsdata = (void *) DatumGetPointer(FunctionCall2(&prs->prsstart,
|
||||
PointerGetDatum(VARDATA(txt)),
|
||||
Int32GetDatum(VARSIZE(txt) - VARHDRSZ)));
|
||||
PointerGetDatum(VARDATA_ANY(txt)),
|
||||
Int32GetDatum(VARSIZE_ANY_EXHDR(txt))));
|
||||
|
||||
while ((type = DatumGetInt32(FunctionCall3(&prs->prstoken,
|
||||
PointerGetDatum(prsdata),
|
||||
@ -248,7 +248,7 @@ ts_parse_byid(PG_FUNCTION_ARGS)
|
||||
|
||||
if (SRF_IS_FIRSTCALL())
|
||||
{
|
||||
text *txt = PG_GETARG_TEXT_P(1);
|
||||
text *txt = PG_GETARG_TEXT_PP(1);
|
||||
|
||||
funcctx = SRF_FIRSTCALL_INIT();
|
||||
prs_setup_firstcall(funcctx, PG_GETARG_OID(0), txt);
|
||||
@ -270,8 +270,8 @@ ts_parse_byname(PG_FUNCTION_ARGS)
|
||||
|
||||
if (SRF_IS_FIRSTCALL())
|
||||
{
|
||||
text *prsname = PG_GETARG_TEXT_P(0);
|
||||
text *txt = PG_GETARG_TEXT_P(1);
|
||||
text *prsname = PG_GETARG_TEXT_PP(0);
|
||||
text *txt = PG_GETARG_TEXT_PP(1);
|
||||
Oid prsId;
|
||||
|
||||
funcctx = SRF_FIRSTCALL_INIT();
|
||||
@ -289,9 +289,9 @@ ts_parse_byname(PG_FUNCTION_ARGS)
|
||||
Datum
|
||||
ts_headline_byid_opt(PG_FUNCTION_ARGS)
|
||||
{
|
||||
text *in = PG_GETARG_TEXT_P(1);
|
||||
text *in = PG_GETARG_TEXT_PP(1);
|
||||
TSQuery query = PG_GETARG_TSQUERY(2);
|
||||
text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_P(3) : NULL;
|
||||
text *opt = (PG_NARGS() > 3 && PG_GETARG_POINTER(3)) ? PG_GETARG_TEXT_PP(3) : NULL;
|
||||
HeadlineParsedText prs;
|
||||
List *prsoptions;
|
||||
text *out;
|
||||
@ -310,7 +310,8 @@ ts_headline_byid_opt(PG_FUNCTION_ARGS)
|
||||
prs.lenwords = 32;
|
||||
prs.words = (HeadlineWordEntry *) palloc(sizeof(HeadlineWordEntry) * prs.lenwords);
|
||||
|
||||
hlparsetext(cfg->cfgId, &prs, query, VARDATA(in), VARSIZE(in) - VARHDRSZ);
|
||||
hlparsetext(cfg->cfgId, &prs, query,
|
||||
VARDATA_ANY(in), VARSIZE_ANY_EXHDR(in));
|
||||
|
||||
if (opt)
|
||||
prsoptions = deserialize_deflist(PointerGetDatum(opt));
|
||||
|
Reference in New Issue
Block a user