@@ -95,7 +95,7 @@ compareentry(const void *va, const void *vb, void *arg)
9595{
9696 const WordEntry2 * a = (const WordEntry2 * ) va ;
9797 const WordEntry2 * b = (const WordEntry2 * ) vb ;
98- TSVector tsv = (TSVector ) arg ;
98+ TSVector2 tsv = (TSVector2 ) arg ;
9999
100100 uint32 offset1 = tsvector2_getoffset (tsv , a - tsvector2_entries (tsv ), NULL ),
101101 offset2 = tsvector2_getoffset (tsv , b - tsvector2_entries (tsv ), NULL );
@@ -198,6 +198,7 @@ uniqueentry(WordEntryIN *a, int l, char *buf, int *outbuflen)
198198 return res + 1 - a ;
199199}
200200
201+ PG_FUNCTION_INFO_V1 (tsvector2in );
201202Datum
202203tsvector2in (PG_FUNCTION_ARGS )
203204{
@@ -207,7 +208,7 @@ tsvector2in(PG_FUNCTION_ARGS)
207208 int totallen ;
208209 int arrlen ; /* allocated size of arr */
209210 int len = 0 ;
210- TSVector in ;
211+ TSVector2 in ;
211212 int i ;
212213 char * token ;
213214 int toklen ;
@@ -223,13 +224,13 @@ tsvector2in(PG_FUNCTION_ARGS)
223224 char * cur ;
224225 int buflen = 256 ; /* allocated size of tmpbuf */
225226
226- state = init_tsvector2_parser (buf , 0 );
227+ state = init_tsvector_parser (buf , 0 );
227228
228229 arrlen = 64 ;
229230 arr = (WordEntryIN * ) palloc (sizeof (WordEntryIN ) * arrlen );
230231 cur = tmpbuf = (char * ) palloc (buflen );
231232
232- while (gettoken_tsvector2 (state , & token , & toklen , & pos , & poslen , NULL ))
233+ while (gettoken_tsvector (state , & token , & toklen , & pos , & poslen , NULL ))
233234 {
234235 if (toklen >= MAXSTRLEN )
235236 ereport (ERROR ,
@@ -271,7 +272,7 @@ tsvector2in(PG_FUNCTION_ARGS)
271272 len ++ ;
272273 }
273274
274- close_tsvector2_parser (state );
275+ close_tsvector_parser (state );
275276
276277 if (len > 0 )
277278 len = uniqueentry (arr , len , tmpbuf , & buflen );
@@ -283,10 +284,10 @@ tsvector2in(PG_FUNCTION_ARGS)
283284 (errcode (ERRCODE_PROGRAM_LIMIT_EXCEEDED ),
284285 errmsg ("string is too long for tsvector2 (%d bytes, max %d bytes)" , buflen , MAXSTRPOS )));
285286
286- totallen = CALCDATASIZE (len , buflen );
287- in = (TSVector ) palloc0 (totallen );
287+ totallen = tsvector2_calcsize (len , buflen );
288+ in = (TSVector2 ) palloc0 (totallen );
288289 SET_VARSIZE (in , totallen );
289- TS_SETCOUNT ( in , len ) ;
290+ in -> size = len ;
290291 stroff = 0 ;
291292 for (i = 0 ; i < len ; i ++ )
292293 {
@@ -298,13 +299,14 @@ tsvector2in(PG_FUNCTION_ARGS)
298299 }
299300
300301 Assert ((tsvector2_storage (in ) + stroff - (char * ) in ) == totallen );
301- PG_RETURN_TSVECTOR (in );
302+ PG_RETURN_TSVECTOR2 (in );
302303}
303304
305+ PG_FUNCTION_INFO_V1 (tsvector2out );
304306Datum
305307tsvector2out (PG_FUNCTION_ARGS )
306308{
307- TSVector out = PG_GETARG_TSVECTOR (0 );
309+ TSVector2 out = PG_GETARG_TSVECTOR2 (0 );
308310 char * outbuf ;
309311 int32 i ,
310312 lenbuf = 0 ,
@@ -404,10 +406,11 @@ tsvector2out(PG_FUNCTION_ARGS)
404406 * uint16 WordEntryPos
405407 */
406408
409+ PG_FUNCTION_INFO_V1 (tsvector2send );
407410Datum
408411tsvector2send (PG_FUNCTION_ARGS )
409412{
410- TSVector vec = PG_GETARG_TSVECTOR (0 );
413+ TSVector2 vec = PG_GETARG_TSVECTOR2 (0 );
411414 StringInfoData buf ;
412415 int i ,
413416 j ;
@@ -425,7 +428,7 @@ tsvector2send(PG_FUNCTION_ARGS)
425428 lex_len = ENTRY_LEN (vec , weptr );
426429
427430 /*
428- * the strings in the TSVector array are not null-terminated, so we
431+ * the strings in the TSVector2 array are not null-terminated, so we
429432 * have to send the null-terminator separately
430433 */
431434 pq_sendtext (& buf , lexeme , lex_len );
@@ -446,14 +449,15 @@ tsvector2send(PG_FUNCTION_ARGS)
446449 PG_RETURN_BYTEA_P (pq_endtypsend (& buf ));
447450}
448451
452+ PG_FUNCTION_INFO_V1 (tsvector2recv );
449453Datum
450454tsvector2recv (PG_FUNCTION_ARGS )
451455{
452456 StringInfo buf = (StringInfo ) PG_GETARG_POINTER (0 );
453- TSVector vec ;
457+ TSVector2 vec ;
454458 int i ,
455459 datalen ; /* number of bytes used in the variable size
456- * area after fixed size TSVector header and
460+ * area after fixed size TSVector2 header and
457461 * WordEntries */
458462 int32 nentries ;
459463 Size hdrlen ;
@@ -466,11 +470,11 @@ tsvector2recv(PG_FUNCTION_ARGS)
466470 if (nentries < 0 || nentries > (MaxAllocSize / sizeof (WordEntry2 )))
467471 elog (ERROR , "invalid size of tsvector2" );
468472
469- hdrlen = DATAHDRSIZE + sizeof (WordEntry2 ) * nentries ;
473+ hdrlen = tsvector2_hdrlen () + sizeof (WordEntry2 ) * nentries ;
470474
471475 len = hdrlen * 2 ; /* times two to make room for lexemes */
472- vec = (TSVector ) palloc0 (len );
473- TS_SETCOUNT ( vec , nentries ) ;
476+ vec = (TSVector2 ) palloc0 (len );
477+ vec -> size = nentries ;
474478
475479 datalen = 0 ;
476480 for (i = 0 ; i < nentries ; i ++ )
@@ -504,7 +508,7 @@ tsvector2recv(PG_FUNCTION_ARGS)
504508 npos * sizeof (WordEntryPos ) >= len )
505509 {
506510 len *= 2 ;
507- vec = (TSVector ) repalloc (vec , len );
511+ vec = (TSVector2 ) repalloc (vec , len );
508512 }
509513
510514 if (prev_lexeme && tsCompareString (lexeme , lex_len ,
@@ -537,5 +541,5 @@ tsvector2recv(PG_FUNCTION_ARGS)
537541 qsort_arg ((void * ) tsvector2_entries (vec ), vec -> size , sizeof (WordEntry2 ),
538542 compareentry , (void * ) vec );
539543
540- PG_RETURN_TSVECTOR (vec );
544+ PG_RETURN_TSVECTOR2 (vec );
541545}
0 commit comments