]> granicus.if.org Git - postgresql/commitdiff
Fixed very stupid but important bug: mixing calls of some founctions from
authorBruce Momjian <bruce@momjian.us>
Sat, 10 Aug 2002 20:46:24 +0000 (20:46 +0000)
committerBruce Momjian <bruce@momjian.us>
Sat, 10 Aug 2002 20:46:24 +0000 (20:46 +0000)
contrib/tsearch and contrib/ltree :)

Teodor Sigaev

contrib/ltree/README.ltree
contrib/ltree/_ltree_gist.c
contrib/ltree/crc32.c
contrib/ltree/crc32.h
contrib/ltree/ltree.h
contrib/ltree/ltree_gist.c
contrib/ltree/ltree_io.c
contrib/ltree/ltxtquery_io.c
contrib/ltree/ltxtquery_op.c

index b11a27bc30d88b0dff86cb7b7464b0a234752dff..c552dca72d602fb4a0888b1939afe8b3c100ff8b 100644 (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;
index 84593deb97ebde07ae2d0b45d3ed2bf0c77abcd5..8b7420e6d9eeba8676013e3fa9bc841ae76e79ba 100644 (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
index 0e04bdb1b0a12772ceff8c403c8522cb485581f1..5cbde4135bf1aa2d6d3202db1ae89b355a43b0e7 100644 (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;
index 97254a4a9094dd0bd5fc8f744305bd41207be97d..f70722c1c5d63db63a628c4b49a7a428ecba8b2c 100644 (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
index a53684370aeabe870e39dea5c75863a2e18a0e36..0c92deeea4aa9271c1cbfffcb045c05495db7bf8 100644 (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);
index 024fd6acbe442156fa40cd17359fa7680c35fb0e..5a4c7bbf5177b3e0b994df12ea23bdef2e11236d 100644 (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
index 2f9e9ed3adf5e313818df6dcf5492c3225b1741e..6fb6d3db9e25665365a51e1389b573a01c37daf7 100644 (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 );
index e056b84bc0fbfbf991427fa4d56f640f411ec69f..59bf0776eeb49c6f18255231fa8e19f068f871c4 100644 (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)
index d5674427e6e4066f97196245cf83cb4615b45259..925385f7e37a538e35624d51b2adf3c820e73b27 100644 (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,