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

Commitef770cb

Browse files
committed
Fixes from Janko Richter <jankorichter@yahoo.de>
- Fix wrong index results on text, char, varchar for multibyte strings- Fix some SIGFPE signals- Add support for infinite timestamps- Because of locale settings, btree_gist can not be a prefix index anymore (for text). Each node holds now just the lower and upper boundary.
1 parent8f6e8e8 commitef770cb

27 files changed

+730
-304
lines changed

‎contrib/btree_gist/btree_bit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ gbt_bit_l2n(GBT_VARKEY * leaf)
9898
staticconstgbtree_vinfotinfo=
9999
{
100100
gbt_t_bit,
101-
FALSE,
101+
0,
102102
TRUE,
103103
gbt_bitgt,
104104
gbt_bitge,

‎contrib/btree_gist/btree_bytea.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ gbt_byteacmp(const bytea *a, const bytea *b)
6565
staticconstgbtree_vinfotinfo=
6666
{
6767
gbt_t_bytea,
68-
FALSE,
68+
0,
6969
TRUE,
7070
gbt_byteagt,
7171
gbt_byteage,

‎contrib/btree_gist/btree_cash.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,10 @@ Datum
125125
gbt_cash_penalty(PG_FUNCTION_ARGS)
126126
{
127127
cashKEY*origentry= (cashKEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(0))->key);
128-
cashKEY*newentry= (cashKEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
129-
float*result= (float*)PG_GETARG_POINTER(2);
128+
cashKEY*newentry= (cashKEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
129+
float*result= (float*)PG_GETARG_POINTER(2);
130130

131-
Cashres;
132-
133-
*result=0.0;
134-
135-
penalty_range_enlarge(origentry->lower,origentry->upper,newentry->lower,newentry->upper);
136-
137-
if (res>0)
138-
{
139-
*result+=FLT_MIN;
140-
*result+= (float) (res / ((double) (res+origentry->upper-origentry->lower)));
141-
*result *= (FLT_MAX / (((GISTENTRY*)PG_GETARG_POINTER(0))->rel->rd_att->natts+1));
142-
}
131+
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
143132

144133
PG_RETURN_POINTER(result);
145134

‎contrib/btree_gist/btree_float4.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,7 @@ gbt_float4_penalty(PG_FUNCTION_ARGS)
127127
float4KEY*newentry= (float4KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
128128
float*result= (float*)PG_GETARG_POINTER(2);
129129

130-
float4res;
131-
132-
*result=0.0;
133-
134-
penalty_range_enlarge(origentry->lower,origentry->upper,newentry->lower,newentry->upper);
135-
136-
if (res>0)
137-
{
138-
*result+=FLT_MIN;
139-
*result+= (float) (res / ((double) (res+origentry->upper-origentry->lower)));
140-
*result *= (FLT_MAX / (((GISTENTRY*)PG_GETARG_POINTER(0))->rel->rd_att->natts+1));
141-
}
130+
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
142131

143132
PG_RETURN_POINTER(result);
144133

‎contrib/btree_gist/btree_float8.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,7 @@ gbt_float8_penalty(PG_FUNCTION_ARGS)
129129
float8KEY*newentry= (float8KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
130130
float*result= (float*)PG_GETARG_POINTER(2);
131131

132-
float8res;
133-
134-
*result=0.0;
135-
136-
penalty_range_enlarge(origentry->lower,origentry->upper,newentry->lower,newentry->upper);
137-
138-
if (res>0)
139-
{
140-
*result+=FLT_MIN;
141-
*result+= (float) (res / ((double) (res+origentry->upper-origentry->lower)));
142-
*result *= (FLT_MAX / (((GISTENTRY*)PG_GETARG_POINTER(0))->rel->rd_att->natts+1));
143-
}
132+
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
144133

145134
PG_RETURN_POINTER(result);
146135

‎contrib/btree_gist/btree_inet.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,8 @@ gbt_inet_penalty(PG_FUNCTION_ARGS)
194194
inetKEY*newentry= (inetKEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
195195
float*result= (float*)PG_GETARG_POINTER(2);
196196

197-
doubleres;
198-
199-
*result=0.0;
200-
201-
penalty_range_enlarge(origentry->lower,origentry->upper,newentry->lower,newentry->upper);
202-
203-
if (res>0)
204-
{
205-
*result+=FLT_MIN;
206-
*result+= (float) (res / ((double) (res+origentry->upper-origentry->lower)));
207-
*result *= (FLT_MAX / (((GISTENTRY*)PG_GETARG_POINTER(0))->rel->rd_att->natts+1));
208-
}
209-
197+
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
198+
210199
PG_RETURN_POINTER(result);
211200

212201
}

‎contrib/btree_gist/btree_int2.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,10 @@ Datum
128128
gbt_int2_penalty(PG_FUNCTION_ARGS)
129129
{
130130
int16KEY*origentry= (int16KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(0))->key);
131-
int16KEY*newentry= (int16KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
132-
float*result= (float*)PG_GETARG_POINTER(2);
133-
int2res;
131+
int16KEY*newentry= (int16KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
132+
float*result= (float*)PG_GETARG_POINTER(2);
134133

135-
*result=0.0;
136-
137-
penalty_range_enlarge(origentry->lower,origentry->upper,newentry->lower,newentry->upper);
138-
139-
if (res>0)
140-
{
141-
*result+=FLT_MIN;
142-
*result+= (float) (res / ((double) (res+origentry->upper-origentry->lower)));
143-
*result *= (FLT_MAX / (((GISTENTRY*)PG_GETARG_POINTER(0))->rel->rd_att->natts+1));
144-
}
134+
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
145135

146136
PG_RETURN_POINTER(result);
147137
}

‎contrib/btree_gist/btree_int4.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,20 +126,10 @@ Datum
126126
gbt_int4_penalty(PG_FUNCTION_ARGS)
127127
{
128128
int32KEY*origentry= (int32KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(0))->key);
129-
int32KEY*newentry= (int32KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
130-
float*result= (float*)PG_GETARG_POINTER(2);
131-
int4res;
132-
133-
*result=0.0;
134-
135-
penalty_range_enlarge(origentry->lower,origentry->upper,newentry->lower,newentry->upper);
136-
137-
if (res>0)
138-
{
139-
*result+=FLT_MIN;
140-
*result+= (float) (res / ((double) (res+origentry->upper-origentry->lower)));
141-
*result *= (FLT_MAX / (((GISTENTRY*)PG_GETARG_POINTER(0))->rel->rd_att->natts+1));
142-
}
129+
int32KEY*newentry= (int32KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
130+
float*result= (float*)PG_GETARG_POINTER(2);
131+
132+
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
143133

144134
PG_RETURN_POINTER(result);
145135
}

‎contrib/btree_gist/btree_int8.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,12 @@ Datum
125125
gbt_int8_penalty(PG_FUNCTION_ARGS)
126126
{
127127
int64KEY*origentry= (int64KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(0))->key);
128-
int64KEY*newentry= (int64KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
129-
float*result= (float*)PG_GETARG_POINTER(2);
130-
int64res;
131-
132-
*result=0.0;
133-
134-
penalty_range_enlarge(origentry->lower,origentry->upper,newentry->lower,newentry->upper);
135-
136-
if (res>0)
137-
{
138-
*result+=FLT_MIN;
139-
*result+= (float) (res / ((double) (res+origentry->upper-origentry->lower)));
140-
*result *= (FLT_MAX / (((GISTENTRY*)PG_GETARG_POINTER(0))->rel->rd_att->natts+1));
141-
}
128+
int64KEY*newentry= (int64KEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
129+
float*result= (float*)PG_GETARG_POINTER(2);
142130

131+
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
132+
143133
PG_RETURN_POINTER(result);
144-
145134
}
146135

147136
Datum

‎contrib/btree_gist/btree_interval.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,24 +203,14 @@ gbt_intv_penalty(PG_FUNCTION_ARGS)
203203
intvKEY*newentry= (intvKEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
204204
float*result= (float*)PG_GETARG_POINTER(2);
205205
doubleiorg[2],
206-
inew[2],
207-
res;
206+
inew[2];
208207

209208
iorg[0]=intr2num(&origentry->lower);
210209
iorg[1]=intr2num(&origentry->upper);
211210
inew[0]=intr2num(&newentry->lower);
212211
inew[1]=intr2num(&newentry->upper);
213212

214-
penalty_range_enlarge(iorg[0],iorg[1],inew[0],inew[1]);
215-
216-
*result=0.0;
217-
218-
if (res>0)
219-
{
220-
*result+=FLT_MIN;
221-
*result+= (float) (res / (res+iorg[1]-iorg[0]));
222-
*result *= (FLT_MAX / (((GISTENTRY*)PG_GETARG_POINTER(0))->rel->rd_att->natts+1));
223-
}
213+
penalty_num(result,iorg[0],iorg[1],inew[0],inew[1]);
224214

225215
PG_RETURN_POINTER(result);
226216

‎contrib/btree_gist/btree_macaddr.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,23 +151,13 @@ gbt_macad_penalty(PG_FUNCTION_ARGS)
151151
float*result= (float*)PG_GETARG_POINTER(2);
152152
uint64iorg[2],
153153
inew[2];
154-
uint64res;
155154

156155
iorg[0]=mac_2_uint64(&origentry->lower);
157156
iorg[1]=mac_2_uint64(&origentry->upper);
158157
inew[0]=mac_2_uint64(&newentry->lower);
159158
inew[1]=mac_2_uint64(&newentry->upper);
160159

161-
penalty_range_enlarge(iorg[0],iorg[1],inew[0],inew[1]);
162-
163-
*result=0.0;
164-
165-
if (res>0)
166-
{
167-
*result+=FLT_MIN;
168-
*result+= (float) (((double)res) / ((double)res+ (double)iorg[1]- (double)iorg[0]));
169-
*result *= (FLT_MAX / (((GISTENTRY*)PG_GETARG_POINTER(0))->rel->rd_att->natts+1));
170-
}
160+
penalty_num(result,iorg[0],iorg[1],inew[0],inew[1]);
171161

172162
PG_RETURN_POINTER(result);
173163

‎contrib/btree_gist/btree_numeric.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ gbt_numeric_cmp(const bytea *a, const bytea *b)
6565
staticconstgbtree_vinfotinfo=
6666
{
6767
gbt_t_numeric,
68-
FALSE,
68+
0,
6969
FALSE,
7070
gbt_numeric_gt,
7171
gbt_numeric_ge,

‎contrib/btree_gist/btree_oid.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,7 @@ gbt_oid_penalty(PG_FUNCTION_ARGS)
129129
oidKEY*newentry= (oidKEY*)DatumGetPointer(((GISTENTRY*)PG_GETARG_POINTER(1))->key);
130130
float*result= (float*)PG_GETARG_POINTER(2);
131131

132-
Oidres=0;
133-
134-
*result=0.0;
135-
136-
penalty_range_enlarge(origentry->lower,origentry->upper,newentry->lower,newentry->upper);
137-
138-
if (res>0)
139-
{
140-
*result+=FLT_MIN;
141-
*result+= (float) (res / ((double) (res+origentry->upper-origentry->lower)));
142-
*result *= (FLT_MAX / (((GISTENTRY*)PG_GETARG_POINTER(0))->rel->rd_att->natts+1));
143-
}
132+
penalty_num(result,origentry->lower,origentry->upper,newentry->lower,newentry->upper);
144133

145134
PG_RETURN_POINTER(result);
146135
}

‎contrib/btree_gist/btree_text.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ gbt_textcmp(const bytea *a, const bytea *b)
6262
returnDatumGetInt32(DirectFunctionCall2(bttextcmp,PointerGetDatum(a),PointerGetDatum(b)));
6363
}
6464

65-
staticconstgbtree_vinfotinfo=
65+
staticgbtree_vinfotinfo=
6666
{
6767
gbt_t_text,
68-
TRUE,
69-
TRUE,
68+
0,
69+
FALSE,
7070
gbt_textgt,
7171
gbt_textge,
7272
gbt_texteq,
@@ -77,7 +77,6 @@ static const gbtree_vinfo tinfo =
7777
};
7878

7979

80-
8180
/**************************************************
8281
* Text ops
8382
**************************************************/
@@ -88,6 +87,11 @@ gbt_text_compress(PG_FUNCTION_ARGS)
8887
{
8988
GISTENTRY*entry= (GISTENTRY*)PG_GETARG_POINTER(0);
9089

90+
if (tinfo.eml==0 )
91+
{
92+
tinfo.eml=pg_database_encoding_max_length();
93+
}
94+
9195
PG_RETURN_POINTER(gbt_var_compress(entry,&tinfo));
9296
}
9397

@@ -98,6 +102,11 @@ gbt_bpchar_compress(PG_FUNCTION_ARGS)
98102
GISTENTRY*entry= (GISTENTRY*)PG_GETARG_POINTER(0);
99103
GISTENTRY*retval;
100104

105+
if (tinfo.eml==0 )
106+
{
107+
tinfo.eml=pg_database_encoding_max_length();
108+
}
109+
101110
if (entry->leafkey)
102111
{
103112

@@ -127,6 +136,11 @@ gbt_text_consistent(PG_FUNCTION_ARGS)
127136
boolretval= FALSE;
128137
GBT_VARKEY_Rr=gbt_var_key_readable(key);
129138

139+
if (tinfo.eml==0 )
140+
{
141+
tinfo.eml=pg_database_encoding_max_length();
142+
}
143+
130144
retval=gbt_var_consistent(&r,query,&strategy,GIST_LEAF(entry),&tinfo);
131145

132146
PG_RETURN_BOOL(retval);
@@ -144,6 +158,11 @@ gbt_bpchar_consistent(PG_FUNCTION_ARGS)
144158
boolretval;
145159
GBT_VARKEY_Rr=gbt_var_key_readable(key);
146160

161+
if (tinfo.eml==0 )
162+
{
163+
tinfo.eml=pg_database_encoding_max_length();
164+
}
165+
147166
retval=gbt_var_consistent(&r,trim,&strategy,GIST_LEAF(entry),&tinfo);
148167
PG_RETURN_BOOL(retval);
149168
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp