diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-08-22 01:39:46 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-08-22 01:39:46 +0000 |
commit | d321421d0a409ee4473c996fd2275df0ff215eaf (patch) | |
tree | 016bb5ca76cb61c0876dbc272eb3eb57171d68d8 /src/backend/utils/cache | |
parent | fd33d90a23150dec944cdfdf4587f7770543acd1 (diff) | |
download | postgresql-d321421d0a409ee4473c996fd2275df0ff215eaf.tar.gz postgresql-d321421d0a409ee4473c996fd2275df0ff215eaf.zip |
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.
Diffstat (limited to 'src/backend/utils/cache')
-rw-r--r-- | src/backend/utils/cache/ts_cache.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/backend/utils/cache/ts_cache.c b/src/backend/utils/cache/ts_cache.c index cd3a9dad571..94051b8c32f 100644 --- a/src/backend/utils/cache/ts_cache.c +++ b/src/backend/utils/cache/ts_cache.c @@ -20,7 +20,7 @@ * Copyright (c) 2006-2007, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/ts_cache.c,v 1.1 2007/08/21 01:11:19 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/ts_cache.c,v 1.2 2007/08/22 01:39:45 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -37,9 +37,9 @@ #include "catalog/pg_ts_parser.h" #include "catalog/pg_ts_template.h" #include "catalog/pg_type.h" +#include "commands/defrem.h" #include "miscadmin.h" #include "tsearch/ts_cache.h" -#include "tsearch/ts_utils.h" #include "utils/array.h" #include "utils/builtins.h" #include "utils/catcache.h" @@ -252,7 +252,7 @@ lookup_ts_dictionary_cache(Oid dictId) tptmpl; Form_pg_ts_dict dict; Form_pg_ts_template template; - MemoryContext saveCtx = NULL; + MemoryContext saveCtx; tpdict = SearchSysCache(TSDICTOID, ObjectIdGetDatum(dictId), @@ -319,21 +319,30 @@ lookup_ts_dictionary_cache(Oid dictId) if (OidIsValid(template->tmplinit)) { - bool isnull; + List *dictoptions; Datum opt; + bool isnull; + MemoryContext oldcontext; + + /* + * Init method runs in dictionary's private memory context, + * and we make sure the options are stored there too + */ + oldcontext = MemoryContextSwitchTo(entry->dictCtx); opt = SysCacheGetAttr(TSDICTOID, tpdict, Anum_pg_ts_dict_dictinitoption, &isnull); if (isnull) - opt = PointerGetDatum(NULL); + dictoptions = NIL; + else + dictoptions = deserialize_deflist(opt); - /* - * Init method runs in dictionary's private memory context - */ - saveCtx = MemoryContextSwitchTo(entry->dictCtx); - entry->dictData = DatumGetPointer(OidFunctionCall1(template->tmplinit, opt)); - MemoryContextSwitchTo(saveCtx); + entry->dictData = + DatumGetPointer(OidFunctionCall1(template->tmplinit, + PointerGetDatum(dictoptions))); + + MemoryContextSwitchTo(oldcontext); } ReleaseSysCache(tptmpl); |