mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Fixed very stupid but important bug: mixing calls of some founctions from
contrib/tsearch and contrib/ltree :) Teodor Sigaev
This commit is contained in:
@ -426,6 +426,8 @@ appreciate your input. So far, below some (rather obvious) results:
|
|||||||
|
|
||||||
CHANGES
|
CHANGES
|
||||||
|
|
||||||
|
Aug 9, 2002
|
||||||
|
Fixed very stupid but important bug :-)
|
||||||
July 31, 2002
|
July 31, 2002
|
||||||
Now works on 64-bit platforms.
|
Now works on 64-bit platforms.
|
||||||
Added function lca - lowest common ancestor
|
Added function lca - lowest common ancestor
|
||||||
@ -437,7 +439,7 @@ July 13, 2002
|
|||||||
TODO
|
TODO
|
||||||
|
|
||||||
* Testing on 64-bit platforms. There are several known problems with byte
|
* Testing on 64-bit platforms. There are several known problems with byte
|
||||||
alignment;
|
alignment; -- RESOLVED
|
||||||
* Better documentation;
|
* Better documentation;
|
||||||
* We plan (probably) to improve regular expressions processing using
|
* We plan (probably) to improve regular expressions processing using
|
||||||
non-deterministic automata;
|
non-deterministic automata;
|
||||||
|
@ -45,7 +45,7 @@ hashing(BITVECP sign, ltree *t) {
|
|||||||
int hash;
|
int hash;
|
||||||
|
|
||||||
while(tlen > 0) {
|
while(tlen > 0) {
|
||||||
hash = crc32_sz( cur->name, cur->len );
|
hash = ltree_crc32_sz( cur->name, cur->len );
|
||||||
AHASH( sign, hash );
|
AHASH( sign, hash );
|
||||||
cur = LEVEL_NEXT(cur);
|
cur = LEVEL_NEXT(cur);
|
||||||
tlen--;
|
tlen--;
|
||||||
@ -455,7 +455,7 @@ gist_te(ltree_gist *key, ltree* query) {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
while( qlen>0 ) {
|
while( qlen>0 ) {
|
||||||
hv = crc32_sz(curq->name,curq->len);
|
hv = ltree_crc32_sz(curq->name,curq->len);
|
||||||
if ( ! GETBIT( sign, AHASHVAL(hv) ) )
|
if ( ! GETBIT( sign, AHASHVAL(hv) ) )
|
||||||
return false;
|
return false;
|
||||||
curq = LEVEL_NEXT(curq);
|
curq = LEVEL_NEXT(curq);
|
||||||
@ -475,7 +475,7 @@ gist_qtxt(ltree_gist *key, ltxtquery* query) {
|
|||||||
if ( LTG_ISALLTRUE(key) )
|
if ( LTG_ISALLTRUE(key) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return execute(
|
return ltree_execute(
|
||||||
GETQUERY(query),
|
GETQUERY(query),
|
||||||
(void*)LTG_SIGN(key), false,
|
(void*)LTG_SIGN(key), false,
|
||||||
checkcondition_bit
|
checkcondition_bit
|
||||||
|
@ -95,7 +95,7 @@ static const unsigned int crc32tab[256] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
crc32_sz(char *buf, int size)
|
ltree_crc32_sz(char *buf, int size)
|
||||||
{
|
{
|
||||||
unsigned int crc = ~0;
|
unsigned int crc = ~0;
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#define _CRC32_H
|
#define _CRC32_H
|
||||||
|
|
||||||
/* Returns crc32 of data block */
|
/* Returns crc32 of data block */
|
||||||
extern unsigned int crc32_sz(char *buf, int size);
|
extern unsigned int ltree_crc32_sz(char *buf, int size);
|
||||||
|
|
||||||
/* Returns crc32 of null-terminated string */
|
/* Returns crc32 of null-terminated string */
|
||||||
#define crc32(buf) crc32_sz((buf),strlen(buf))
|
#define crc32(buf) ltree_crc32_sz((buf),strlen(buf))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -152,7 +152,7 @@ Datum ltree_textadd(PG_FUNCTION_ARGS);
|
|||||||
/* Util function */
|
/* Util function */
|
||||||
Datum ltree_in(PG_FUNCTION_ARGS);
|
Datum ltree_in(PG_FUNCTION_ARGS);
|
||||||
|
|
||||||
bool execute(ITEM * curitem, void *checkval,
|
bool ltree_execute(ITEM * curitem, void *checkval,
|
||||||
bool calcnot, bool (*chkcond) (void *checkval, ITEM * val));
|
bool calcnot, bool (*chkcond) (void *checkval, ITEM * val));
|
||||||
|
|
||||||
int ltree_compare(const ltree *a, const ltree *b);
|
int ltree_compare(const ltree *a, const ltree *b);
|
||||||
|
@ -130,7 +130,7 @@ hashing(BITVECP sign, ltree *t) {
|
|||||||
int hash;
|
int hash;
|
||||||
|
|
||||||
while(tlen > 0) {
|
while(tlen > 0) {
|
||||||
hash = crc32_sz( cur->name, cur->len );
|
hash = ltree_crc32_sz( cur->name, cur->len );
|
||||||
HASH( sign, hash );
|
HASH( sign, hash );
|
||||||
cur = LEVEL_NEXT(cur);
|
cur = LEVEL_NEXT(cur);
|
||||||
tlen--;
|
tlen--;
|
||||||
@ -511,7 +511,7 @@ gist_qtxt(ltree_gist *key, ltxtquery* query) {
|
|||||||
if ( LTG_ISALLTRUE(key) )
|
if ( LTG_ISALLTRUE(key) )
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return execute(
|
return ltree_execute(
|
||||||
GETQUERY(query),
|
GETQUERY(query),
|
||||||
(void*)LTG_SIGN(key), false,
|
(void*)LTG_SIGN(key), false,
|
||||||
checkcondition_bit
|
checkcondition_bit
|
||||||
|
@ -333,7 +333,7 @@ lquery_in(PG_FUNCTION_ARGS) {
|
|||||||
cur->totallen += MAXALIGN(LVAR_HDRSIZE + lptr->len);
|
cur->totallen += MAXALIGN(LVAR_HDRSIZE + lptr->len);
|
||||||
lrptr->len = lptr->len;
|
lrptr->len = lptr->len;
|
||||||
lrptr->flag = lptr->flag;
|
lrptr->flag = lptr->flag;
|
||||||
lrptr->val = crc32_sz((uint8 *) lptr->start, lptr->len);
|
lrptr->val = ltree_crc32_sz((uint8 *) lptr->start, lptr->len);
|
||||||
memcpy( lrptr->name, lptr->start, lptr->len);
|
memcpy( lrptr->name, lptr->start, lptr->len);
|
||||||
lptr++;
|
lptr++;
|
||||||
lrptr = LVAR_NEXT( lrptr );
|
lrptr = LVAR_NEXT( lrptr );
|
||||||
|
@ -154,7 +154,7 @@ pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval, uint16 flag
|
|||||||
if (lenval > 0xffff)
|
if (lenval > 0xffff)
|
||||||
elog(ERROR, "Word is too long");
|
elog(ERROR, "Word is too long");
|
||||||
|
|
||||||
pushquery(state, type, crc32_sz((uint8 *) strval, lenval),
|
pushquery(state, type, ltree_crc32_sz((uint8 *) strval, lenval),
|
||||||
state->curop - state->op, lenval, flag);
|
state->curop - state->op, lenval, flag);
|
||||||
|
|
||||||
while (state->curop - state->op + lenval + 1 >= state->lenop)
|
while (state->curop - state->op + lenval + 1 >= state->lenop)
|
||||||
|
@ -13,23 +13,23 @@ PG_FUNCTION_INFO_V1(ltxtq_rexec);
|
|||||||
* check for boolean condition
|
* check for boolean condition
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
execute(ITEM * curitem, void *checkval, bool calcnot, bool (*chkcond) (void *checkval, ITEM * val)) {
|
ltree_execute(ITEM * curitem, void *checkval, bool calcnot, bool (*chkcond) (void *checkval, ITEM * val)) {
|
||||||
if (curitem->type == VAL)
|
if (curitem->type == VAL)
|
||||||
return (*chkcond) (checkval, curitem);
|
return (*chkcond) (checkval, curitem);
|
||||||
else if (curitem->val == (int4) '!') {
|
else if (curitem->val == (int4) '!') {
|
||||||
return (calcnot) ?
|
return (calcnot) ?
|
||||||
((execute(curitem + 1, checkval, calcnot, chkcond)) ? false : true)
|
((ltree_execute(curitem + 1, checkval, calcnot, chkcond)) ? false : true)
|
||||||
: true;
|
: true;
|
||||||
} else if (curitem->val == (int4) '&') {
|
} else if (curitem->val == (int4) '&') {
|
||||||
if (execute(curitem + curitem->left, checkval, calcnot, chkcond))
|
if (ltree_execute(curitem + curitem->left, checkval, calcnot, chkcond))
|
||||||
return execute(curitem + 1, checkval, calcnot, chkcond);
|
return ltree_execute(curitem + 1, checkval, calcnot, chkcond);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
} else { /* |-operator */
|
} else { /* |-operator */
|
||||||
if (execute(curitem + curitem->left, checkval, calcnot, chkcond))
|
if (ltree_execute(curitem + curitem->left, checkval, calcnot, chkcond))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return execute(curitem + 1, checkval, calcnot, chkcond);
|
return ltree_execute(curitem + 1, checkval, calcnot, chkcond);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ ltxtq_exec(PG_FUNCTION_ARGS) {
|
|||||||
chkval.node = val;
|
chkval.node = val;
|
||||||
chkval.operand = GETOPERAND(query);
|
chkval.operand = GETOPERAND(query);
|
||||||
|
|
||||||
result = execute(
|
result = ltree_execute(
|
||||||
GETQUERY(query),
|
GETQUERY(query),
|
||||||
&chkval,
|
&chkval,
|
||||||
true,
|
true,
|
||||||
|
Reference in New Issue
Block a user