mirror of
https://github.com/postgres/postgres.git
synced 2025-05-27 00:04:24 -04:00
Simplify CREATE TEXT SEARCH CONFIGURATION by eliminating the separate
'with map' parameter; as things now stand there's really not much point in specifying a config-to-copy if you don't copy its map. Also, use COPY instead of TEMPLATE as the key word for a config-to-copy, so as to avoid confusion with text search templates. Per discussion; the just-committed reference page for the command already describes it this way.
This commit is contained in:
parent
3e3bb36ee9
commit
fd33d90a23
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/tsearchcmds.c,v 1.1 2007/08/21 01:11:15 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/tsearchcmds.c,v 1.2 2007/08/21 21:24:00 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1192,10 +1192,9 @@ DefineTSConfiguration(List *names, List *parameters)
|
|||||||
Oid namespaceoid;
|
Oid namespaceoid;
|
||||||
char *cfgname;
|
char *cfgname;
|
||||||
NameData cname;
|
NameData cname;
|
||||||
List *templateName = NIL;
|
List *sourceName = NIL;
|
||||||
Oid templateOid = InvalidOid;
|
Oid sourceOid = InvalidOid;
|
||||||
Oid prsOid = InvalidOid;
|
Oid prsOid = InvalidOid;
|
||||||
bool with_map = false;
|
|
||||||
Oid cfgOid;
|
Oid cfgOid;
|
||||||
ListCell *pl;
|
ListCell *pl;
|
||||||
|
|
||||||
@ -1217,10 +1216,8 @@ DefineTSConfiguration(List *names, List *parameters)
|
|||||||
|
|
||||||
if (pg_strcasecmp(defel->defname, "parser") == 0)
|
if (pg_strcasecmp(defel->defname, "parser") == 0)
|
||||||
prsOid = TSParserGetPrsid(defGetQualifiedName(defel), false);
|
prsOid = TSParserGetPrsid(defGetQualifiedName(defel), false);
|
||||||
else if (pg_strcasecmp(defel->defname, "template") == 0)
|
else if (pg_strcasecmp(defel->defname, "copy") == 0)
|
||||||
templateName = defGetQualifiedName(defel);
|
sourceName = defGetQualifiedName(defel);
|
||||||
else if (pg_strcasecmp(defel->defname, "map") == 0)
|
|
||||||
with_map = defGetBoolean(defel);
|
|
||||||
else
|
else
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||||
@ -1229,26 +1226,24 @@ DefineTSConfiguration(List *names, List *parameters)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Look up template if given. XXX the "template" is an existing config
|
* Look up source config if given.
|
||||||
* that we copy, not a pg_ts_template entry. This seems confusing.
|
|
||||||
* Maybe should use "source" or some other word?
|
|
||||||
*/
|
*/
|
||||||
if (templateName)
|
if (sourceName)
|
||||||
{
|
{
|
||||||
Form_pg_ts_config cfg;
|
Form_pg_ts_config cfg;
|
||||||
|
|
||||||
templateOid = TSConfigGetCfgid(templateName, false);
|
sourceOid = TSConfigGetCfgid(sourceName, false);
|
||||||
|
|
||||||
tup = SearchSysCache(TSCONFIGOID,
|
tup = SearchSysCache(TSCONFIGOID,
|
||||||
ObjectIdGetDatum(templateOid),
|
ObjectIdGetDatum(sourceOid),
|
||||||
0, 0, 0);
|
0, 0, 0);
|
||||||
if (!HeapTupleIsValid(tup))
|
if (!HeapTupleIsValid(tup))
|
||||||
elog(ERROR, "cache lookup failed for text search configuration %u",
|
elog(ERROR, "cache lookup failed for text search configuration %u",
|
||||||
templateOid);
|
sourceOid);
|
||||||
|
|
||||||
cfg = (Form_pg_ts_config) GETSTRUCT(tup);
|
cfg = (Form_pg_ts_config) GETSTRUCT(tup);
|
||||||
|
|
||||||
/* Use template's parser if no other was specified */
|
/* Use source's parser if no other was specified */
|
||||||
if (!OidIsValid(prsOid))
|
if (!OidIsValid(prsOid))
|
||||||
prsOid = cfg->cfgparser;
|
prsOid = cfg->cfgparser;
|
||||||
|
|
||||||
@ -1283,10 +1278,10 @@ DefineTSConfiguration(List *names, List *parameters)
|
|||||||
|
|
||||||
CatalogUpdateIndexes(cfgRel, tup);
|
CatalogUpdateIndexes(cfgRel, tup);
|
||||||
|
|
||||||
if (OidIsValid(templateOid) && with_map)
|
if (OidIsValid(sourceOid))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Copy token-dicts map from template
|
* Copy token-dicts map from source config
|
||||||
*/
|
*/
|
||||||
ScanKeyData skey;
|
ScanKeyData skey;
|
||||||
SysScanDesc scan;
|
SysScanDesc scan;
|
||||||
@ -1297,7 +1292,7 @@ DefineTSConfiguration(List *names, List *parameters)
|
|||||||
ScanKeyInit(&skey,
|
ScanKeyInit(&skey,
|
||||||
Anum_pg_ts_config_map_mapcfg,
|
Anum_pg_ts_config_map_mapcfg,
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
BTEqualStrategyNumber, F_OIDEQ,
|
||||||
ObjectIdGetDatum(templateOid));
|
ObjectIdGetDatum(sourceOid));
|
||||||
|
|
||||||
scan = systable_beginscan(mapRel, TSConfigMapIndexId, true,
|
scan = systable_beginscan(mapRel, TSConfigMapIndexId, true,
|
||||||
SnapshotNow, 1, &skey);
|
SnapshotNow, 1, &skey);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user