mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-12 18:34:36 +08:00
Fix rwrite(ARRAY) on 64-bit boxes:
Instead of getting elements of array manually call deconstruct_array
This commit is contained in:
parent
0645663e6c
commit
134bed8089
@ -13,12 +13,12 @@ psql:tsearch2.sql:342: NOTICE: argument type tsvector is only a shell
|
|||||||
psql:tsearch2.sql:396: NOTICE: type "tsquery" is not yet defined
|
psql:tsearch2.sql:396: NOTICE: type "tsquery" is not yet defined
|
||||||
DETAIL: Creating a shell type definition.
|
DETAIL: Creating a shell type definition.
|
||||||
psql:tsearch2.sql:401: NOTICE: argument type tsquery is only a shell
|
psql:tsearch2.sql:401: NOTICE: argument type tsquery is only a shell
|
||||||
psql:tsearch2.sql:543: NOTICE: type "gtsvector" is not yet defined
|
psql:tsearch2.sql:544: NOTICE: type "gtsvector" is not yet defined
|
||||||
DETAIL: Creating a shell type definition.
|
DETAIL: Creating a shell type definition.
|
||||||
psql:tsearch2.sql:548: NOTICE: argument type gtsvector is only a shell
|
psql:tsearch2.sql:549: NOTICE: argument type gtsvector is only a shell
|
||||||
psql:tsearch2.sql:997: NOTICE: type "gtsq" is not yet defined
|
psql:tsearch2.sql:998: NOTICE: type "gtsq" is not yet defined
|
||||||
DETAIL: Creating a shell type definition.
|
DETAIL: Creating a shell type definition.
|
||||||
psql:tsearch2.sql:1002: NOTICE: argument type gtsq is only a shell
|
psql:tsearch2.sql:1003: NOTICE: argument type gtsq is only a shell
|
||||||
--tsvector
|
--tsvector
|
||||||
SELECT '1'::tsvector;
|
SELECT '1'::tsvector;
|
||||||
tsvector
|
tsvector
|
||||||
|
@ -201,6 +201,8 @@ rewrite_accum(PG_FUNCTION_ARGS) {
|
|||||||
QUERYTYPE *q;
|
QUERYTYPE *q;
|
||||||
QTNode *qex, *subs = NULL, *acctree;
|
QTNode *qex, *subs = NULL, *acctree;
|
||||||
bool isfind = false;
|
bool isfind = false;
|
||||||
|
Datum *elemsp;
|
||||||
|
int nelemsp;
|
||||||
|
|
||||||
AggregateContext = ((AggState *) fcinfo->context)->aggcontext;
|
AggregateContext = ((AggState *) fcinfo->context)->aggcontext;
|
||||||
|
|
||||||
@ -230,14 +232,19 @@ rewrite_accum(PG_FUNCTION_ARGS) {
|
|||||||
if (ARR_ELEMTYPE(qa) != tsqOid)
|
if (ARR_ELEMTYPE(qa) != tsqOid)
|
||||||
elog(ERROR, "array should contain tsquery type");
|
elog(ERROR, "array should contain tsquery type");
|
||||||
|
|
||||||
q = (QUERYTYPE*)ARR_DATA_PTR(qa);
|
deconstruct_array(qa, tsqOid, -1, false, 'i', &elemsp, &nelemsp);
|
||||||
if ( q->size == 0 )
|
|
||||||
|
q = (QUERYTYPE*)DatumGetPointer( elemsp[0] );
|
||||||
|
if ( q->size == 0 ) {
|
||||||
|
pfree( elemsp );
|
||||||
PG_RETURN_POINTER( acc );
|
PG_RETURN_POINTER( acc );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !acc->size ) {
|
if ( !acc->size ) {
|
||||||
if ( acc->len > HDRSIZEQT )
|
if ( acc->len > HDRSIZEQT ) {
|
||||||
|
pfree( elemsp );
|
||||||
PG_RETURN_POINTER( acc );
|
PG_RETURN_POINTER( acc );
|
||||||
else
|
} else
|
||||||
acctree = QT2QTN( GETQUERY(q), GETOPERAND(q) );
|
acctree = QT2QTN( GETQUERY(q), GETOPERAND(q) );
|
||||||
} else
|
} else
|
||||||
acctree = QT2QTN( GETQUERY(acc), GETOPERAND(acc) );
|
acctree = QT2QTN( GETQUERY(acc), GETOPERAND(acc) );
|
||||||
@ -245,14 +252,16 @@ rewrite_accum(PG_FUNCTION_ARGS) {
|
|||||||
QTNTernary( acctree );
|
QTNTernary( acctree );
|
||||||
QTNSort( acctree );
|
QTNSort( acctree );
|
||||||
|
|
||||||
q = (QUERYTYPE*)( ((char*)ARR_DATA_PTR(qa)) + MAXALIGN( q->len ) );
|
q = (QUERYTYPE*)DatumGetPointer( elemsp[1] );
|
||||||
if ( q->size == 0 )
|
if ( q->size == 0 ) {
|
||||||
|
pfree( elemsp );
|
||||||
PG_RETURN_POINTER( acc );
|
PG_RETURN_POINTER( acc );
|
||||||
|
}
|
||||||
qex = QT2QTN( GETQUERY(q), GETOPERAND(q) );
|
qex = QT2QTN( GETQUERY(q), GETOPERAND(q) );
|
||||||
QTNTernary( qex );
|
QTNTernary( qex );
|
||||||
QTNSort( qex );
|
QTNSort( qex );
|
||||||
|
|
||||||
q = (QUERYTYPE*)( ((char*)q) + MAXALIGN( q->len ) );
|
q = (QUERYTYPE*)DatumGetPointer( elemsp[2] );
|
||||||
if ( q->size )
|
if ( q->size )
|
||||||
subs = QT2QTN( GETQUERY(q), GETOPERAND(q) );
|
subs = QT2QTN( GETQUERY(q), GETOPERAND(q) );
|
||||||
|
|
||||||
@ -270,6 +279,7 @@ rewrite_accum(PG_FUNCTION_ARGS) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pfree( elemsp );
|
||||||
QTNFree( qex );
|
QTNFree( qex );
|
||||||
QTNFree( subs );
|
QTNFree( subs );
|
||||||
QTNFree( acctree );
|
QTNFree( acctree );
|
||||||
|
@ -402,6 +402,7 @@ LANGUAGE 'C' with (isstrict);
|
|||||||
|
|
||||||
CREATE TYPE tsquery (
|
CREATE TYPE tsquery (
|
||||||
INTERNALLENGTH = -1,
|
INTERNALLENGTH = -1,
|
||||||
|
ALIGNMENT = int4,
|
||||||
INPUT = tsquery_in,
|
INPUT = tsquery_in,
|
||||||
OUTPUT = tsquery_out
|
OUTPUT = tsquery_out
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user