1 /*-------------------------------------------------------------------------
4 * Standard interface to dictionary
6 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
12 *-------------------------------------------------------------------------
16 #include "catalog/pg_type.h"
17 #include "tsearch/ts_cache.h"
18 #include "tsearch/ts_utils.h"
19 #include "utils/builtins.h"
23 * Lexize one word by dictionary, mostly debug function
26 ts_lexize(PG_FUNCTION_ARGS
)
28 Oid dictId
= PG_GETARG_OID(0);
29 text
*in
= PG_GETARG_TEXT_P(1);
31 TSDictionaryCacheEntry
*dict
;
35 DictSubState dstate
= {false, false, NULL
};
37 dict
= lookup_ts_dictionary_cache(dictId
);
39 res
= (TSLexeme
*) DatumGetPointer(FunctionCall4(&dict
->lexize
,
40 PointerGetDatum(dict
->dictData
),
41 PointerGetDatum(VARDATA(in
)),
42 Int32GetDatum(VARSIZE(in
) - VARHDRSZ
),
43 PointerGetDatum(&dstate
)));
48 ptr
= (TSLexeme
*) DatumGetPointer(FunctionCall4(&dict
->lexize
,
49 PointerGetDatum(dict
->dictData
),
50 PointerGetDatum(VARDATA(in
)),
51 Int32GetDatum(VARSIZE(in
) - VARHDRSZ
),
52 PointerGetDatum(&dstate
)));
63 da
= (Datum
*) palloc(sizeof(Datum
) * (ptr
- res
));
67 da
[ptr
- res
] = CStringGetTextDatum(ptr
->lexeme
);
71 a
= construct_array(da
,
81 pfree(DatumGetPointer(da
[ptr
- res
]));