12.10. Поддержка psql
Информацию об объектах конфигурации текстового поиска можно получить в psql с помощью следующего набора команд:
\dF{d,p,t}[+] [ШАБЛОН]
Необязательный +
в этих командах включает более подробный вывод.
В необязательном параметре ШАБЛОН
может указываться имя объекта текстового поиска (возможно, дополненное схемой). Если ШАБЛОН
не указан, выводится информация обо всех видимых объектах. ШАБЛОН
может содержать регулярное выражение с разными масками для схемы и объекта. Это иллюстрируют следующие примеры:
=> \dF *fulltext* List of text search configurations Schema | Name | Description --------+--------------+------------- public | fulltext_cfg |
=> \dF *.fulltext* List of text search configurations Schema | Name | Description ----------+---------------------------- fulltext | fulltext_cfg | public | fulltext_cfg |
Возможны следующие команды:
\dF[+] [ШАБЛОН]
Список конфигураций текстового поиска (добавьте
+
для дополнительных сведений).=> \dF russian List of text search configurations Schema | Name | Description ------------+---------+------------------------------------ pg_catalog | russian | configuration for russian language => \dF+ russian Text search configuration "pg_catalog.russian" Parser: "pg_catalog.default" Token | Dictionaries -----------------+-------------- asciihword | english_stem asciiword | english_stem email | simple file | simple float | simple host | simple hword | russian_stem hword_asciipart | english_stem hword_numpart | simple hword_part | russian_stem int | simple numhword | simple numword | simple sfloat | simple uint | simple url | simple url_path | simple version | simple word | russian_stem
\dFd[+] [ШАБЛОН]
Список словарей текстового поиска (добавьте
+
для дополнительных сведений).=> \dFd List of text search dictionaries Schema | Name | Description -----------+----------------+------------------------------------------- pg_catalog | danish_stem | snowball stemmer for danish language pg_catalog | dutch_stem | snowball stemmer for dutch language pg_catalog | english_stem | snowball stemmer for english language pg_catalog | finnish_stem | snowball stemmer for finnish language pg_catalog | french_stem | snowball stemmer for french language pg_catalog | german_stem | snowball stemmer for german language pg_catalog | hungarian_stem | snowball stemmer for hungarian language pg_catalog | italian_stem | snowball stemmer for italian language pg_catalog | norwegian_stem | snowball stemmer for norwegian language pg_catalog | portuguese_stem| snowball stemmer for portuguese language pg_catalog | romanian_stem | snowball stemmer for romanian language pg_catalog | russian_stem | snowball stemmer for russian language pg_catalog | simple | simple dictionary: just lower case and ... pg_catalog | spanish_stem | snowball stemmer for spanish language pg_catalog | swedish_stem | snowball stemmer for swedish language pg_catalog | turkish_stem | snowball stemmer for turkish language
\dFp[+] [ШАБЛОН]
Список анализаторов текстового поиска (добавьте
+
для дополнительных сведений).=> \dFp List of text search parsers Schema | Name | Description ------------+---------+--------------------- pg_catalog | default | default word parser => \dFp+ Text search parser "pg_catalog.default" Method | Function | Description -----------------+----------------+------------- Start parse | prsd_start | Get next token | prsd_nexttoken | End parse | prsd_end | Get headline | prsd_headline | Get token types | prsd_lextype | Token types for parser "pg_catalog.default" Token name | Description -----------------+------------------------------------------ asciihword | Hyphenated word, all ASCII asciiword | Word, all ASCII blank | Space symbols email | Email address entity | XML entity file | File or path name float | Decimal notation host | Host hword | Hyphenated word, all letters hword_asciipart | Hyphenated word part, all ASCII hword_numpart | Hyphenated word part, letters and digits hword_part | Hyphenated word part, all letters int | Signed integer numhword | Hyphenated word, letters and digits numword | Word, letters and digits protocol | Protocol head sfloat | Scientific notation tag | XML tag uint | Unsigned integer url | URL url_path | URL path version | Version number word | Word, all letters (23 rows)
\dFt[+] [ШАБЛОН]
Список шаблонов текстового поиска (добавьте
+
для дополнительных сведений).=> \dFt List of text search templates Schema | Name | Description ----------+---------+---------------------------------------------------- pg_catalog|ispell |ispell dictionary pg_catalog|simple |simple dictionary: just lower case and check for ... pg_catalog|snowball |snowball stemmer pg_catalog|synonym |synonym dictionary: replace word by its synonym pg_catalog|thesaurus|thesaurus dictionary: phrase by phrase substitution
45.4. Expressions
All expressions used in PL/pgSQL statements are processed using the server's main SQL executor. For example, when you write a PL/pgSQL statement like
IF expression
THEN ...
PL/pgSQL will evaluate the expression by feeding a query like
SELECT expression
to the main SQL engine. While forming the SELECT
command, any occurrences of PL/pgSQL variable names are replaced by query parameters, as discussed in detail in Section 45.12.1. This allows the query plan for the SELECT
to be prepared just once and then reused for subsequent evaluations with different values of the variables. Thus, what really happens on first use of an expression is essentially a PREPARE
command. For example, if we have declared two integer variables x
and y
, and we write
IF x < y THEN ...
what happens behind the scenes is equivalent to
PREPARE statement_name
(integer, integer) AS SELECT $1 < $2;
and then this prepared statement is EXECUTE
d for each execution of the IF
statement, with the current values of the PL/pgSQL variables supplied as parameter values. Normally these details are not important to a PL/pgSQL user, but they are useful to know when trying to diagnose a problem. More information appears in Section 45.12.2.
Since an expression
is converted to a SELECT
command, it can contain the same clauses that an ordinary SELECT
would, except that it cannot include a top-level UNION
, INTERSECT
, or EXCEPT
clause. Thus for example one could test whether a table is non-empty with
IF count(*) > 0 FROM my_table THEN ...
since the expression
between IF
and THEN
is parsed as though it were SELECT count(*) > 0 FROM my_table
. The SELECT
must produce a single column, and not more than one row. (If it produces no rows, the result is taken as NULL.)