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

Commitfb13881

Browse files
committed
1 fix various comparing functions
2 implement gtsvector_out for use with gevel module (debug GiST indexes,http://www.sai.msu.su/~megera/postgres/gist/gevel/)
1 parentfd97743 commitfb13881

File tree

6 files changed

+35
-10
lines changed

6 files changed

+35
-10
lines changed

‎contrib/tsearch2/dict.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ reset_dict(void)
9292
staticint
9393
comparedict(constvoid*a,constvoid*b)
9494
{
95-
return ((DictInfo*)a)->dict_id- ((DictInfo*)b)->dict_id;
95+
if ( ((DictInfo*)a)->dict_id== ((DictInfo*)b)->dict_id )
96+
return0;
97+
return ( ((DictInfo*)a)->dict_id< ((DictInfo*)b)->dict_id ) ?-1 :1;
9698
}
9799

98100
DictInfo*

‎contrib/tsearch2/gistidx.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ Datumgtsvector_picksplit(PG_FUNCTION_ARGS);
5454
GETBITBYTE(val,7)\
5555
)
5656

57+
staticint4sizebitvec(BITVECPsign);
5758

5859
Datum
5960
gtsvector_in(PG_FUNCTION_ARGS)
@@ -64,13 +65,31 @@ gtsvector_in(PG_FUNCTION_ARGS)
6465
PG_RETURN_DATUM(0);
6566
}
6667

68+
#defineSINGOUTSTR"%d true bits, %d false bits"
69+
#defineARROUTSTR"%d unique words"
70+
#defineEXTRALEN( 2*13 )
71+
72+
staticintoutbuf_maxlen=0;
73+
6774
Datum
6875
gtsvector_out(PG_FUNCTION_ARGS)
6976
{
70-
ereport(ERROR,
71-
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
72-
errmsg("gtsvector_out not implemented")));
73-
PG_RETURN_DATUM(0);
77+
GISTTYPE*key= (GISTTYPE*)DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_POINTER(0)));
78+
char*outbuf;
79+
80+
if (outbuf_maxlen==0 )
81+
outbuf_maxlen=2*EXTRALEN+Max(strlen(SINGOUTSTR),strlen(ARROUTSTR) )+1;
82+
outbuf=palloc(outbuf_maxlen );
83+
84+
if (ISARRKEY(key) )
85+
sprintf(outbuf,ARROUTSTR,ARRNELEM(key) );
86+
else {
87+
intcnttrue= (ISALLTRUE(key) ) ?SIGLENBIT :sizebitvec(GETSIGN(key));
88+
sprintf(outbuf,SINGOUTSTR,cnttrue,SIGLENBIT-cnttrue );
89+
}
90+
91+
PG_FREE_IF_COPY(key,0);
92+
PG_RETURN_POINTER(outbuf);
7493
}
7594

7695
staticint

‎contrib/tsearch2/rank.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ static int
386386
compareDocR(constvoid*a,constvoid*b)
387387
{
388388
if (((DocRepresentation*)a)->pos== ((DocRepresentation*)b)->pos)
389-
return1;
389+
return0;
390390
return (((DocRepresentation*)a)->pos> ((DocRepresentation*)b)->pos) ?1 :-1;
391391
}
392392

@@ -654,7 +654,7 @@ static int
654654
compareDocWord(constvoid*a,constvoid*b)
655655
{
656656
if (((DocWord*)a)->pos== ((DocWord*)b)->pos)
657-
return1;
657+
return0;
658658
return (((DocWord*)a)->pos> ((DocWord*)b)->pos) ?1 :-1;
659659
}
660660

‎contrib/tsearch2/ts_cfg.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ reset_cfg(void)
186186
staticint
187187
comparecfg(constvoid*a,constvoid*b)
188188
{
189-
return ((TSCfgInfo*)a)->id- ((TSCfgInfo*)b)->id;
189+
if ( ((TSCfgInfo*)a)->id== ((TSCfgInfo*)b)->id )
190+
return0;
191+
return ( ((TSCfgInfo*)a)->id< ((TSCfgInfo*)b)->id ) ?-1 :1;
190192
}
191193

192194
TSCfgInfo*

‎contrib/tsearch2/tsvector.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int
5151
comparePos(constvoid*a,constvoid*b)
5252
{
5353
if (WEP_GETPOS(*(WordEntryPos*)a)==WEP_GETPOS(*(WordEntryPos*)b))
54-
return1;
54+
return0;
5555
return (WEP_GETPOS(*(WordEntryPos*)a)>WEP_GETPOS(*(WordEntryPos*)b)) ?1 :-1;
5656
}
5757

‎contrib/tsearch2/wparser.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ reset_prs(void)
9393
staticint
9494
compareprs(constvoid*a,constvoid*b)
9595
{
96-
return ((WParserInfo*)a)->prs_id- ((WParserInfo*)b)->prs_id;
96+
if ( ((WParserInfo*)a)->prs_id== ((WParserInfo*)b)->prs_id )
97+
return0;
98+
return ( ((WParserInfo*)a)->prs_id< ((WParserInfo*)b)->prs_id ) ?-1 :1;
9799
}
98100

99101
WParserInfo*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp