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

Commit134bed8

Browse files
committed
Fix rwrite(ARRAY) on 64-bit boxes:
Instead of getting elements of array manually call deconstruct_array
1 parent0645663 commit134bed8

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

‎contrib/tsearch2/expected/tsearch2.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ psql:tsearch2.sql:342: NOTICE: argument type tsvector is only a shell
1313
psql:tsearch2.sql:396: NOTICE: type "tsquery" is not yet defined
1414
DETAIL: Creating a shell type definition.
1515
psql:tsearch2.sql:401: NOTICE: argument type tsquery is only a shell
16-
psql:tsearch2.sql:543: NOTICE: type "gtsvector" is not yet defined
16+
psql:tsearch2.sql:544: NOTICE: type "gtsvector" is not yet defined
1717
DETAIL: Creating a shell type definition.
18-
psql:tsearch2.sql:548: NOTICE: argument type gtsvector is only a shell
19-
psql:tsearch2.sql:997: NOTICE: type "gtsq" is not yet defined
18+
psql:tsearch2.sql:549: NOTICE: argument type gtsvector is only a shell
19+
psql:tsearch2.sql:998: NOTICE: type "gtsq" is not yet defined
2020
DETAIL: Creating a shell type definition.
21-
psql:tsearch2.sql:1002: NOTICE: argument type gtsq is only a shell
21+
psql:tsearch2.sql:1003: NOTICE: argument type gtsq is only a shell
2222
--tsvector
2323
SELECT '1'::tsvector;
2424
tsvector

‎contrib/tsearch2/query_rewrite.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ rewrite_accum(PG_FUNCTION_ARGS) {
201201
QUERYTYPE*q;
202202
QTNode*qex,*subs=NULL,*acctree;
203203
boolisfind= false;
204+
Datum*elemsp;
205+
intnelemsp;
204206

205207
AggregateContext= ((AggState*)fcinfo->context)->aggcontext;
206208

@@ -230,29 +232,36 @@ rewrite_accum(PG_FUNCTION_ARGS) {
230232
if (ARR_ELEMTYPE(qa)!=tsqOid)
231233
elog(ERROR,"array should contain tsquery type");
232234

233-
q= (QUERYTYPE*)ARR_DATA_PTR(qa);
234-
if (q->size==0 )
235+
deconstruct_array(qa,tsqOid,-1, false,'i',&elemsp,&nelemsp);
236+
237+
q= (QUERYTYPE*)DatumGetPointer(elemsp[0] );
238+
if (q->size==0 ) {
239+
pfree(elemsp );
235240
PG_RETURN_POINTER(acc );
241+
}
236242

237243
if ( !acc->size ) {
238-
if (acc->len>HDRSIZEQT )
244+
if (acc->len>HDRSIZEQT ) {
245+
pfree(elemsp );
239246
PG_RETURN_POINTER(acc );
240-
else
247+
}else
241248
acctree=QT2QTN(GETQUERY(q),GETOPERAND(q) );
242249
}else
243250
acctree=QT2QTN(GETQUERY(acc),GETOPERAND(acc) );
244251

245252
QTNTernary(acctree );
246253
QTNSort(acctree );
247254

248-
q= (QUERYTYPE*)( ((char*)ARR_DATA_PTR(qa))+MAXALIGN(q->len ) );
249-
if (q->size==0 )
255+
q= (QUERYTYPE*)DatumGetPointer(elemsp[1] );
256+
if (q->size==0 ) {
257+
pfree(elemsp );
250258
PG_RETURN_POINTER(acc );
259+
}
251260
qex=QT2QTN(GETQUERY(q),GETOPERAND(q) );
252261
QTNTernary(qex );
253262
QTNSort(qex );
254263

255-
q= (QUERYTYPE*)( ((char*)q)+MAXALIGN(q->len ) );
264+
q= (QUERYTYPE*)DatumGetPointer(elemsp[2] );
256265
if (q->size )
257266
subs=QT2QTN(GETQUERY(q),GETOPERAND(q) );
258267

@@ -270,6 +279,7 @@ rewrite_accum(PG_FUNCTION_ARGS) {
270279
}
271280
}
272281

282+
pfree(elemsp );
273283
QTNFree(qex );
274284
QTNFree(subs );
275285
QTNFree(acctree );

‎contrib/tsearch2/tsearch.sql.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ LANGUAGE 'C' with (isstrict);
402402

403403
CREATE TYPE tsquery (
404404
INTERNALLENGTH = -1,
405+
ALIGNMENT = int4,
405406
INPUT = tsquery_in,
406407
OUTPUT = tsquery_out
407408
);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp