pgsql: Simplify the syntax of CREATE/ALTER TEXT SEARCH DICTIONARY by

Started by Nonameover 18 years ago5 messages
#1Noname
tgl@postgresql.org

Log Message:
-----------
Simplify the syntax of CREATE/ALTER TEXT SEARCH DICTIONARY by treating the
init options of the template as top-level options in the syntax. This also
makes ALTER a bit easier to use, since options can be replaced individually.
I also made these statements verify that the tmplinit method will accept
the new settings before they get stored; in the original coding you didn't
find out about mistakes until the dictionary got invoked.

Under the hood, init methods now get options as a List of DefElem instead
of a raw text string --- that lets tsearch use existing options-pushing code
instead of duplicating functionality.

Modified Files:
--------------
pgsql/doc/src/sgml/ref:
alter_tsdictionary.sgml (r1.1 -> r1.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/ref/alter_tsdictionary.sgml?r1=1.1&r2=1.2)
create_tsdictionary.sgml (r1.1 -> r1.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/ref/create_tsdictionary.sgml?r1=1.1&r2=1.2)
pgsql/src/backend/commands:
tsearchcmds.c (r1.2 -> r1.3)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/tsearchcmds.c?r1=1.2&r2=1.3)
pgsql/src/backend/snowball:
dict_snowball.c (r1.1 -> r1.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/snowball/dict_snowball.c?r1=1.1&r2=1.2)
snowball.sql.in (r1.1 -> r1.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/snowball/snowball.sql.in?r1=1.1&r2=1.2)
pgsql/src/backend/tsearch:
dict_ispell.c (r1.1 -> r1.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/tsearch/dict_ispell.c?r1=1.1&r2=1.2)
dict_simple.c (r1.1 -> r1.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/tsearch/dict_simple.c?r1=1.1&r2=1.2)
dict_thesaurus.c (r1.1 -> r1.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/tsearch/dict_thesaurus.c?r1=1.1&r2=1.2)
ts_utils.c (r1.1 -> r1.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/tsearch/ts_utils.c?r1=1.1&r2=1.2)
wparser.c (r1.1 -> r1.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/tsearch/wparser.c?r1=1.1&r2=1.2)
wparser_def.c (r1.1 -> r1.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/tsearch/wparser_def.c?r1=1.1&r2=1.2)
pgsql/src/backend/utils/cache:
ts_cache.c (r1.1 -> r1.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/cache/ts_cache.c?r1=1.1&r2=1.2)
pgsql/src/bin/pg_dump:
pg_dump.c (r1.470 -> r1.471)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/bin/pg_dump/pg_dump.c?r1=1.470&r2=1.471)
pgsql/src/include/catalog:
catversion.h (r1.416 -> r1.417)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/catversion.h?r1=1.416&r2=1.417)
pg_proc.h (r1.463 -> r1.464)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_proc.h?r1=1.463&r2=1.464)
pgsql/src/include/commands:
defrem.h (r1.83 -> r1.84)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/commands/defrem.h?r1=1.83&r2=1.84)
pgsql/src/include/tsearch:
ts_public.h (r1.1 -> r1.2)
(http://developer.postgresql.org/cvsweb.cgi/pgsql/src/include/tsearch/ts_public.h?r1=1.1&r2=1.2)

#2Teodor Sigaev
teodor@sigaev.ru
In reply to: Noname (#1)
Re: pgsql: Simplify the syntax of CREATE/ALTER TEXT SEARCH DICTIONARY by

the new settings before they get stored; in the original coding you didn't
find out about mistakes until the dictionary got invoked.

That is source of initdb error with -E KOI8-R --locale ru_RU.KOI8-R options :
ERROR: character 0xc3a5 of encoding "UTF8" has no equivalent in "KOI8"

Snowball dictionary tries to convert swedish (some languages too, but that was
first which I see) stopword file from UTF8 to KOI8 encoding.

--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Teodor Sigaev (#2)
Re: [COMMITTERS] pgsql: Simplify the syntax of CREATE/ALTER TEXT SEARCH DICTIONARY by

Teodor Sigaev <teodor@sigaev.ru> writes:

I also made these statements verify that the tmplinit method will accept
the new settings before they get stored; in the original coding you didn't
find out about mistakes until the dictionary got invoked.

That is source of initdb error with -E KOI8-R --locale ru_RU.KOI8-R options :
ERROR: character 0xc3a5 of encoding "UTF8" has no equivalent in "KOI8"

Snowball dictionary tries to convert swedish (some languages too, but
that was first which I see) stopword file from UTF8 to KOI8 encoding.

Hmm. That's a problem, but I don't think that not having any error
checking on CREATE TEXT SEARCH DICTIONARY's parameters is a good
solution.

The first kluge that comes to mind is to suppress the error check in a
standalone backend (ie, when not IsUnderPostmaster), which would cover
the initdb case. But maybe there are better answers ... any ideas?

regards, tom lane

#4Teodor Sigaev
teodor@sigaev.ru
In reply to: Tom Lane (#3)
Re: [COMMITTERS] pgsql: Simplify the syntax of CREATE/ALTER TEXT SEARCH DICTIONARY by

Hmm. That's a problem, but I don't think that not having any error
checking on CREATE TEXT SEARCH DICTIONARY's parameters is a good
solution.

Agreed

The first kluge that comes to mind is to suppress the error check in a
standalone backend (ie, when not IsUnderPostmaster), which would cover
the initdb case. But maybe there are better answers ... any ideas?

Don't see, but that's connected only to snowball stemmers - other dictionaries
are not created in initdb time.

--
Teodor Sigaev E-mail: teodor@sigaev.ru
WWW: http://www.sigaev.ru/

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Teodor Sigaev (#4)
Re: [COMMITTERS] pgsql: Simplify the syntax of CREATE/ALTER TEXT SEARCH DICTIONARY by

Teodor Sigaev <teodor@sigaev.ru> writes:

The first kluge that comes to mind is to suppress the error check in a
standalone backend (ie, when not IsUnderPostmaster), which would cover
the initdb case. But maybe there are better answers ... any ideas?

Don't see, but that's connected only to snowball stemmers - other dictionaries
are not created in initdb time.

True today, but might not always be so. ISTM the generic issue here is
that initdb wants to set up prefab dictionaries that might not actually
be usable in the specific database encoding that template1 is assigned.
But making them anyway is correct, since they could still be used later
in some other database created with a different encoding. So I'm
inclined to put the disable check into the generic verify_dictoptions()
routine, not into snowball specifically.

regards, tom lane