Chao Li <[email protected]> writes:
> Overall looks good to me. A few small comments:
> 1 - 0001
> ```
> + unsigned int dist = pq_getmsgint(buf,
> sizeof(int16));
> +
> + if (dist > MAXENTRYPOS)
> + elog(ERROR, "invalid tsquery: invalid
> phrase distance %d",
> + dist);
> ```
> Here, “dist” is an unsigned int, so maybe it would be better to use “%u” than
> “%d” to print it.
Hmm ... doesn't really matter, since pq_getmsgint's result is
guaranteed to be in 0..65535. But OK.
> 2 - 0002
> ···
> + <para>The length of a <type>tsquery</type>'s data (lexemes only)
> + must be less than 1 megabyte</para>
> ···
> Look like to me this is inaccurate, because in pushValue_internal(), the "if
> (distance > MAXSTRPOS)” check happens before adding a new element, thus
> distance may exceed MAXSTRPOS after the element is added.
True, it can be up to one lexeme more. But I didn't think it was
worth trying to go into that much detail. As a comparison point,
the corresponding bullet for tsvector doesn't explain how to calculate
the space used for lexeme positions. I think the main takeaway here
is just that there *is* a limit of this type. People who really want
to know the exact details can consult the source code.
regards, tom lane