Re: new function for tsquery creartion
От | Dmitry Ivanov |
---|---|
Тема | Re: new function for tsquery creartion |
Дата | |
Msg-id | 9153fb21831d0ba7c832960f37df2688@postgrespro.ru обсуждение исходный текст |
Ответ на | Re: new function for tsquery creartion (Dmitry Ivanov <d.ivanov@postgrespro.ru>) |
Ответы |
Re: new function for tsquery creartion
Re: new function for tsquery creartion Re: new function for tsquery creartion |
Список | pgsql-hackers |
Hi everyone, I'd like to share some intermediate results. Here's what has changed: 1. OR operator is now case-insensitive. Moreover, trailing whitespace is no longer used to identify it: select websearch_to_tsquery('simple', 'abc or'); websearch_to_tsquery ---------------------- 'abc' & 'or' (1 row) select websearch_to_tsquery('simple', 'abc or(def)'); websearch_to_tsquery ---------------------- 'abc' | 'def' (1 row) select websearch_to_tsquery('simple', 'abc or!def'); websearch_to_tsquery ---------------------- 'abc' | 'def' (1 row) 2. AROUND(N) has been dropped. I hope that <N, M> operator will allow us to implement it with a few lines of code. 3. websearch_to_tsquery() now tolerates various syntax errors, for instance: Misused operators: 'abc &' '| abc' '<- def' Missing parentheses: 'abc & (def <-> (cat or rat' Other sorts of nonsense: 'abc &--|| def' => 'abc' & !!'def' 'abc:def' => 'abc':D & 'ef' This, however, doesn't mean that the result will always be adequate (who would have thought?). Overall, current implementation follows the GIGO principle. In theory, this would allow us to use user-supplied websearch strings (but see gotchas), even if they don't make much sense. Better then nothing, right? 4. A small refactoring: I've replaced all WAIT* macros with a enum for better debugging (names look much nicer in GDB). Hope this is acceptable. 5. Finally, I've added a few more comments and tests. I haven't checked the code coverage, though. A few gotchas: I haven't touched gettoken_tsvector() yet. As a result, the following queries produce errors: select websearch_to_tsquery('simple', ''''); ERROR: syntax error in tsquery: "'" select websearch_to_tsquery('simple', '\'); ERROR: there is no escaped character: "\" Maybe there's more. The question is: should we fix those, or it's fine as it is? I don't have a strong opinion about this. -- Dmitry Ivanov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company
Вложения
В списке pgsql-hackers по дате отправления: