Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit638bd34

Browse files
committed
Found another small glitch in tsearch API: the two versions of ts_lexize()
are really redundant, since we invented a regdictionary alias type.We can have just one function, declared as taking regdictionary, andit will handle both behaviors. Noted while working on documentation.
1 parentba6b0bf commit638bd34

File tree

4 files changed

+15
-60
lines changed

4 files changed

+15
-60
lines changed

‎src/backend/tsearch/dict.c

Lines changed: 9 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,31 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/tsearch/dict.c,v 1.1 2007/08/2101:11:18 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/tsearch/dict.c,v 1.2 2007/10/19 22:01:45 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
1414
#include"postgres.h"
1515

16-
#include"funcapi.h"
17-
#include"access/genam.h"
18-
#include"access/heapam.h"
19-
#include"access/skey.h"
20-
#include"catalog/indexing.h"
21-
#include"catalog/namespace.h"
22-
#include"catalog/pg_ts_dict.h"
2316
#include"catalog/pg_type.h"
2417
#include"tsearch/ts_cache.h"
25-
#include"tsearch/ts_public.h"
2618
#include"tsearch/ts_utils.h"
27-
#include"utils/array.h"
2819
#include"utils/builtins.h"
29-
#include"utils/fmgroids.h"
30-
#include"utils/rel.h"
31-
#include"utils/syscache.h"
3220

3321

3422
/*
3523
* Lexize one word by dictionary, mostly debug function
3624
*/
37-
staticArrayType*
38-
ts_lexize_workhorse(OiddictId,text*in)
25+
Datum
26+
ts_lexize(PG_FUNCTION_ARGS)
3927
{
28+
OiddictId=PG_GETARG_OID(0);
29+
text*in=PG_GETARG_TEXT_P(1);
30+
ArrayType*a;
4031
TSDictionaryCacheEntry*dict;
4132
TSLexeme*res,
4233
*ptr;
4334
Datum*da;
44-
ArrayType*a;
4535
DictSubStatedstate= {false, false,NULL};
4636

4737
dict=lookup_ts_dictionary_cache(dictId);
@@ -65,12 +55,12 @@ ts_lexize_workhorse(Oid dictId, text *in)
6555
}
6656

6757
if (!res)
68-
returnNULL;
58+
PG_RETURN_NULL();
6959

7060
ptr=res;
7161
while (ptr->lexeme)
7262
ptr++;
73-
da= (Datum*)palloc(sizeof(Datum)* (ptr-res+1));
63+
da= (Datum*)palloc(sizeof(Datum)* (ptr-res));
7464
ptr=res;
7565
while (ptr->lexeme)
7666
{
@@ -95,37 +85,5 @@ ts_lexize_workhorse(Oid dictId, text *in)
9585
pfree(res);
9686
pfree(da);
9787

98-
returna;
99-
}
100-
101-
Datum
102-
ts_lexize_byid(PG_FUNCTION_ARGS)
103-
{
104-
OiddictId=PG_GETARG_OID(0);
105-
text*in=PG_GETARG_TEXT_P(1);
106-
ArrayType*a;
107-
108-
a=ts_lexize_workhorse(dictId,in);
109-
110-
if (a)
111-
PG_RETURN_POINTER(a);
112-
else
113-
PG_RETURN_NULL();
114-
}
115-
116-
Datum
117-
ts_lexize_byname(PG_FUNCTION_ARGS)
118-
{
119-
text*dictname=PG_GETARG_TEXT_P(0);
120-
text*in=PG_GETARG_TEXT_P(1);
121-
OiddictId;
122-
ArrayType*a;
123-
124-
dictId=TSDictionaryGetDictid(textToQualifiedNameList(dictname), false);
125-
a=ts_lexize_workhorse(dictId,in);
126-
127-
if (a)
128-
PG_RETURN_POINTER(a);
129-
else
130-
PG_RETURN_NULL();
88+
PG_RETURN_POINTER(a);
13189
}

‎src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.433 2007/10/1919:48:34 tgl Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.434 2007/10/1922:01:45 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO200710191
56+
#defineCATALOG_VERSION_NO200710192
5757

5858
#endif

‎src/include/catalog/pg_proc.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.475 2007/10/1919:48:34 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.476 2007/10/1922:01:45 tgl Exp $
1111
*
1212
* NOTES
1313
* The script catalog/genbki.sh reads this file and generates .bki
@@ -4326,9 +4326,7 @@ DESCR("");
43264326
DATA(insertOID=3721 (prsd_lextypePGNSPPGUID1210fftfi12281"2281"_null__null__null_prsd_lextype-_null__null_ ));
43274327
DESCR("");
43284328

4329-
DATA(insertOID=3723 (ts_lexizePGNSPPGUID1210fftfi21009"26 25"_null__null__null_ts_lexize_byid-_null__null_ ));
4330-
DESCR("normalize one word by dictionary");
4331-
DATA(insertOID=3724 (ts_lexizePGNSPPGUID1210fftfs21009"25 25"_null__null__null_ts_lexize_byname-_null__null_ ));
4329+
DATA(insertOID=3723 (ts_lexizePGNSPPGUID1210fftfi21009"3769 25"_null__null__null_ts_lexize-_null__null_ ));
43324330
DESCR("normalize one word by dictionary");
43334331

43344332
DATA(insertOID=3725 (dsimple_initPGNSPPGUID1210fftfi12281"2281"_null__null__null_dsimple_init-_null__null_ ));

‎src/include/tsearch/ts_utils.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1998-2007, PostgreSQL Global Development Group
77
*
8-
* $PostgreSQL: pgsql/src/include/tsearch/ts_utils.h,v 1.4 2007/09/10 12:36:41 teodor Exp $
8+
* $PostgreSQL: pgsql/src/include/tsearch/ts_utils.h,v 1.5 2007/10/19 22:01:45 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -222,8 +222,7 @@ extern Datum prsd_lextype(PG_FUNCTION_ARGS);
222222
/*
223223
* Dictionary interface to SQL
224224
*/
225-
externDatumts_lexize_byid(PG_FUNCTION_ARGS);
226-
externDatumts_lexize_byname(PG_FUNCTION_ARGS);
225+
externDatumts_lexize(PG_FUNCTION_ARGS);
227226

228227
/*
229228
* Simple built-in dictionary

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp