Fixed very stupid but important bug: mixing calls of some founctions from

contrib/tsearch and contrib/ltree :)

Teodor Sigaev
This commit is contained in:
Bruce Momjian 2002-08-10 20:46:24 +00:00
parent be2de3b9c8
commit 87cfb8eb29
9 changed files with 21 additions and 19 deletions

View File

@ -426,6 +426,8 @@ appreciate your input. So far, below some (rather obvious) results:
CHANGES
Aug 9, 2002
Fixed very stupid but important bug :-)
July 31, 2002
Now works on 64-bit platforms.
Added function lca - lowest common ancestor
@ -437,7 +439,7 @@ July 13, 2002
TODO
* Testing on 64-bit platforms. There are several known problems with byte
alignment;
alignment; -- RESOLVED
* Better documentation;
* We plan (probably) to improve regular expressions processing using
non-deterministic automata;

View File

@ -45,7 +45,7 @@ hashing(BITVECP sign, ltree *t) {
int hash;
while(tlen > 0) {
hash = crc32_sz( cur->name, cur->len );
hash = ltree_crc32_sz( cur->name, cur->len );
AHASH( sign, hash );
cur = LEVEL_NEXT(cur);
tlen--;
@ -455,7 +455,7 @@ gist_te(ltree_gist *key, ltree* query) {
return true;
while( qlen>0 ) {
hv = crc32_sz(curq->name,curq->len);
hv = ltree_crc32_sz(curq->name,curq->len);
if ( ! GETBIT( sign, AHASHVAL(hv) ) )
return false;
curq = LEVEL_NEXT(curq);
@ -475,7 +475,7 @@ gist_qtxt(ltree_gist *key, ltxtquery* query) {
if ( LTG_ISALLTRUE(key) )
return true;
return execute(
return ltree_execute(
GETQUERY(query),
(void*)LTG_SIGN(key), false,
checkcondition_bit

View File

@ -95,7 +95,7 @@ static const unsigned int crc32tab[256] = {
};
unsigned int
crc32_sz(char *buf, int size)
ltree_crc32_sz(char *buf, int size)
{
unsigned int crc = ~0;
char *p;

View File

@ -2,9 +2,9 @@
#define _CRC32_H
/* 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 */
#define crc32(buf) crc32_sz((buf),strlen(buf))
#define crc32(buf) ltree_crc32_sz((buf),strlen(buf))
#endif

View File

@ -152,7 +152,7 @@ Datum ltree_textadd(PG_FUNCTION_ARGS);
/* Util function */
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));
int ltree_compare(const ltree *a, const ltree *b);

View File

@ -130,7 +130,7 @@ hashing(BITVECP sign, ltree *t) {
int hash;
while(tlen > 0) {
hash = crc32_sz( cur->name, cur->len );
hash = ltree_crc32_sz( cur->name, cur->len );
HASH( sign, hash );
cur = LEVEL_NEXT(cur);
tlen--;
@ -511,7 +511,7 @@ gist_qtxt(ltree_gist *key, ltxtquery* query) {
if ( LTG_ISALLTRUE(key) )
return true;
return execute(
return ltree_execute(
GETQUERY(query),
(void*)LTG_SIGN(key), false,
checkcondition_bit

View File

@ -333,7 +333,7 @@ lquery_in(PG_FUNCTION_ARGS) {
cur->totallen += MAXALIGN(LVAR_HDRSIZE + lptr->len);
lrptr->len = lptr->len;
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);
lptr++;
lrptr = LVAR_NEXT( lrptr );

View File

@ -154,7 +154,7 @@ pushval_asis(QPRS_STATE * state, int type, char *strval, int lenval, uint16 flag
if (lenval > 0xffff)
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);
while (state->curop - state->op + lenval + 1 >= state->lenop)

View File

@ -13,23 +13,23 @@ PG_FUNCTION_INFO_V1(ltxtq_rexec);
* check for boolean condition
*/
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)
return (*chkcond) (checkval, curitem);
else if (curitem->val == (int4) '!') {
return (calcnot) ?
((execute(curitem + 1, checkval, calcnot, chkcond)) ? false : true)
((ltree_execute(curitem + 1, checkval, calcnot, chkcond)) ? false : true)
: true;
} else if (curitem->val == (int4) '&') {
if (execute(curitem + curitem->left, checkval, calcnot, chkcond))
return execute(curitem + 1, checkval, calcnot, chkcond);
if (ltree_execute(curitem + curitem->left, checkval, calcnot, chkcond))
return ltree_execute(curitem + 1, checkval, calcnot, chkcond);
else
return false;
} else { /* |-operator */
if (execute(curitem + curitem->left, checkval, calcnot, chkcond))
if (ltree_execute(curitem + curitem->left, checkval, calcnot, chkcond))
return true;
else
return execute(curitem + 1, checkval, calcnot, chkcond);
return ltree_execute(curitem + 1, checkval, calcnot, chkcond);
}
return false;
}
@ -76,7 +76,7 @@ ltxtq_exec(PG_FUNCTION_ARGS) {
chkval.node = val;
chkval.operand = GETOPERAND(query);
result = execute(
result = ltree_execute(
GETQUERY(query),
&chkval,
true,