Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
11864ab6
Commit
11864ab6
authored
May 31, 2004
by
Teodor Sigaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Win32 related patch by Darko Prenosil. Small correct by teodor
parent
9b178555
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
20 deletions
+38
-20
contrib/tsearch2/ispell/spell.c
contrib/tsearch2/ispell/spell.c
+19
-4
contrib/tsearch2/ispell/spell.h
contrib/tsearch2/ispell/spell.h
+2
-1
contrib/tsearch2/query.c
contrib/tsearch2/query.c
+1
-1
contrib/tsearch2/ts_cfg.c
contrib/tsearch2/ts_cfg.c
+1
-1
contrib/tsearch2/ts_cfg.h
contrib/tsearch2/ts_cfg.h
+4
-2
contrib/tsearch2/tsvector.c
contrib/tsearch2/tsvector.c
+11
-11
No files found.
contrib/tsearch2/ispell/spell.c
View file @
11864ab6
...
...
@@ -619,6 +619,9 @@ static char *
CheckAffix
(
const
char
*
word
,
size_t
len
,
AFFIX
*
Affix
,
char
flagflags
,
char
*
newword
)
{
regmatch_t
subs
[
2
];
/* workaround for apache&linux */
int
err
;
pg_wchar
*
data
;
size_t
data_len
;
int
dat_len
;
if
(
flagflags
&
FF_COMPOUNDONLYAFX
)
{
if
(
(
Affix
->
flagflags
&
FF_COMPOUNDONLYAFX
)
==
0
)
...
...
@@ -638,17 +641,29 @@ CheckAffix(const char *word, size_t len, AFFIX * Affix, char flagflags, char *ne
if
(
Affix
->
compile
)
{
err
=
regcomp
(
&
(
Affix
->
reg
),
Affix
->
mask
,
REG_EXTENDED
|
REG_ICASE
|
REG_NOSUB
);
int
wmasklen
,
masklen
=
strlen
(
Affix
->
mask
);
pg_wchar
*
mask
;
mask
=
(
pg_wchar
*
)
palloc
((
masklen
+
1
)
*
sizeof
(
pg_wchar
));
wmasklen
=
pg_mb2wchar_with_len
(
Affix
->
mask
,
mask
,
masklen
);
err
=
pg_regcomp
(
&
(
Affix
->
reg
),
mask
,
wmasklen
,
REG_EXTENDED
|
REG_ICASE
|
REG_NOSUB
);
if
(
err
)
{
/* regerror(err, &(Affix->reg), regerrstr, ERRSTRSIZE); */
regfree
(
&
(
Affix
->
reg
));
pg_
regfree
(
&
(
Affix
->
reg
));
return
(
NULL
);
}
Affix
->
compile
=
0
;
}
if
(
!
(
err
=
regexec
(
&
(
Affix
->
reg
),
newword
,
1
,
subs
,
0
)))
/* Convert data string to wide characters */
dat_len
=
strlen
(
newword
);
data
=
(
pg_wchar
*
)
palloc
((
dat_len
+
1
)
*
sizeof
(
pg_wchar
));
data_len
=
pg_mb2wchar_with_len
(
newword
,
data
,
dat_len
);
if
(
!
(
err
=
pg_regexec
(
&
(
Affix
->
reg
),
data
,
dat_len
,
NULL
,
1
,
subs
,
0
)))
return
newword
;
return
NULL
;
}
...
...
@@ -995,7 +1010,7 @@ NIFree(IspellDict * Conf)
for
(
i
=
0
;
i
<
Conf
->
naffixes
;
i
++
)
{
if
(
Affix
[
i
].
compile
==
0
)
regfree
(
&
(
Affix
[
i
].
reg
));
pg_
regfree
(
&
(
Affix
[
i
].
reg
));
}
if
(
Conf
->
Spell
)
{
for
(
i
=
0
;
i
<
Conf
->
nspell
;
i
++
)
...
...
contrib/tsearch2/ispell/spell.h
View file @
11864ab6
...
...
@@ -2,9 +2,10 @@
#define __SPELL_H__
#include <sys/types.h>
#include
<regex.h>
#include
"regex/regex.h"
#include "c.h"
struct
SPNode
;
...
...
contrib/tsearch2/query.c
View file @
11864ab6
...
...
@@ -269,7 +269,7 @@ pushval_morph(QPRS_STATE * state, int typeval, char *strval, int lenval, int2 we
prs
.
lenwords
=
32
;
prs
.
curwords
=
0
;
prs
.
pos
=
0
;
prs
.
words
=
(
WORD
*
)
palloc
(
sizeof
(
WORD
)
*
prs
.
lenwords
);
prs
.
words
=
(
TSWORD
*
)
palloc
(
sizeof
(
TS
WORD
)
*
prs
.
lenwords
);
parsetext_v2
(
findcfg
(
state
->
cfg_id
),
&
prs
,
strval
,
lenval
);
...
...
contrib/tsearch2/ts_cfg.c
View file @
11864ab6
...
...
@@ -338,7 +338,7 @@ parsetext_v2(TSCfgInfo * cfg, PRSTEXT * prs, char *buf, int4 buflen)
if
(
prs
->
curwords
==
prs
->
lenwords
)
{
prs
->
lenwords
*=
2
;
prs
->
words
=
(
WORD
*
)
repalloc
((
void
*
)
prs
->
words
,
prs
->
lenwords
*
sizeof
(
WORD
));
prs
->
words
=
(
TSWORD
*
)
repalloc
((
void
*
)
prs
->
words
,
prs
->
lenwords
*
sizeof
(
TS
WORD
));
}
prs
->
words
[
prs
->
curwords
].
len
=
strlen
(
*
ptr
);
...
...
contrib/tsearch2/ts_cfg.h
View file @
11864ab6
#ifndef __TS_CFG_H__
#define __TS_CFG_H__
#include "postgres.h"
#include "query.h"
typedef
struct
{
int
len
;
...
...
@@ -32,11 +34,11 @@ typedef struct
}
pos
;
char
*
word
;
uint32
alen
;
}
WORD
;
}
TS
WORD
;
typedef
struct
{
WORD
*
words
;
TS
WORD
*
words
;
int4
lenwords
;
int4
curwords
;
int4
pos
;
...
...
contrib/tsearch2/tsvector.c
View file @
11864ab6
...
...
@@ -573,24 +573,24 @@ tsvector_out(PG_FUNCTION_ARGS)
static
int
compareWORD
(
const
void
*
a
,
const
void
*
b
)
{
if
(((
WORD
*
)
a
)
->
len
==
((
WORD
*
)
b
)
->
len
)
if
(((
TSWORD
*
)
a
)
->
len
==
((
TS
WORD
*
)
b
)
->
len
)
{
int
res
=
strncmp
(
((
WORD
*
)
a
)
->
word
,
((
WORD
*
)
b
)
->
word
,
((
WORD
*
)
b
)
->
len
);
((
TS
WORD
*
)
a
)
->
word
,
((
TS
WORD
*
)
b
)
->
word
,
((
TS
WORD
*
)
b
)
->
len
);
if
(
res
==
0
)
return
(((
WORD
*
)
a
)
->
pos
.
pos
>
((
WORD
*
)
b
)
->
pos
.
pos
)
?
1
:
-
1
;
return
(((
TSWORD
*
)
a
)
->
pos
.
pos
>
((
TS
WORD
*
)
b
)
->
pos
.
pos
)
?
1
:
-
1
;
return
res
;
}
return
(((
WORD
*
)
a
)
->
len
>
((
WORD
*
)
b
)
->
len
)
?
1
:
-
1
;
return
(((
TSWORD
*
)
a
)
->
len
>
((
TS
WORD
*
)
b
)
->
len
)
?
1
:
-
1
;
}
static
int
uniqueWORD
(
WORD
*
a
,
int4
l
)
uniqueWORD
(
TS
WORD
*
a
,
int4
l
)
{
WORD
*
ptr
,
TS
WORD
*
ptr
,
*
res
;
int
tmppos
;
...
...
@@ -607,7 +607,7 @@ uniqueWORD(WORD * a, int4 l)
res
=
a
;
ptr
=
a
+
1
;
qsort
((
void
*
)
a
,
l
,
sizeof
(
WORD
),
compareWORD
);
qsort
((
void
*
)
a
,
l
,
sizeof
(
TS
WORD
),
compareWORD
);
tmppos
=
LIMITPOS
(
a
->
pos
.
pos
);
a
->
alen
=
2
;
a
->
pos
.
apos
=
(
uint16
*
)
palloc
(
sizeof
(
uint16
)
*
a
->
alen
);
...
...
@@ -728,7 +728,7 @@ to_tsvector(PG_FUNCTION_ARGS)
prs
.
lenwords
=
32
;
prs
.
curwords
=
0
;
prs
.
pos
=
0
;
prs
.
words
=
(
WORD
*
)
palloc
(
sizeof
(
WORD
)
*
prs
.
lenwords
);
prs
.
words
=
(
TSWORD
*
)
palloc
(
sizeof
(
TS
WORD
)
*
prs
.
lenwords
);
parsetext_v2
(
cfg
,
&
prs
,
VARDATA
(
in
),
VARSIZE
(
in
)
-
VARHDRSZ
);
PG_FREE_IF_COPY
(
in
,
1
);
...
...
@@ -853,7 +853,7 @@ tsearch2(PG_FUNCTION_ARGS)
prs
.
lenwords
=
32
;
prs
.
curwords
=
0
;
prs
.
pos
=
0
;
prs
.
words
=
(
WORD
*
)
palloc
(
sizeof
(
WORD
)
*
prs
.
lenwords
);
prs
.
words
=
(
TSWORD
*
)
palloc
(
sizeof
(
TS
WORD
)
*
prs
.
lenwords
);
/* find all words in indexable column */
for
(
i
=
1
;
i
<
trigger
->
tgnargs
;
i
++
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment