@ -9,7 +9,7 @@
*
*
* 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 ;
char * cfgname ;
NameData cname ;
List * templat eName = NIL ;
Oid templat eOid = InvalidOid ;
List * sourc eName = NIL ;
Oid sourc eOid = InvalidOid ;
Oid prsOid = InvalidOid ;
bool with_map = false ;
Oid cfgOid ;
ListCell * pl ;
@ -1217,10 +1216,8 @@ DefineTSConfiguration(List *names, List *parameters)
if ( pg_strcasecmp ( defel - > defname , " parser " ) = = 0 )
prsOid = TSParserGetPrsid ( defGetQualifiedName ( defel ) , false ) ;
else if ( pg_strcasecmp ( defel - > defname , " template " ) = = 0 )
templateName = defGetQualifiedName ( defel ) ;
else if ( pg_strcasecmp ( defel - > defname , " map " ) = = 0 )
with_map = defGetBoolean ( defel ) ;
else if ( pg_strcasecmp ( defel - > defname , " copy " ) = = 0 )
sourceName = defGetQualifiedName ( defel ) ;
else
ereport ( 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
* that we copy , not a pg_ts_template entry . This seems confusing .
* Maybe should use " source " or some other word ?
* Look up source config if given .
*/
if ( templat eName)
if ( sourceName )
{
Form_pg_ts_config cfg ;
templat eOid = TSConfigGetCfgid ( templat eName, false ) ;
sourc eOid = TSConfigGetCfgid ( sourc eName, false ) ;
tup = SearchSysCache ( TSCONFIGOID ,
ObjectIdGetDatum ( templat eOid) ,
ObjectIdGetDatum ( sourc eOid) ,
0 , 0 , 0 ) ;
if ( ! HeapTupleIsValid ( tup ) )
elog ( ERROR , " cache lookup failed for text search configuration %u " ,
templat eOid) ;
sourc eOid) ;
cfg = ( Form_pg_ts_config ) GETSTRUCT ( tup ) ;
/* Use templat e's parser if no other was specified */
/* Use sourc e's parser if no other was specified */
if ( ! OidIsValid ( prsOid ) )
prsOid = cfg - > cfgparser ;
@ -1283,10 +1278,10 @@ DefineTSConfiguration(List *names, List *parameters)
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 ;
SysScanDesc scan ;
@ -1297,7 +1292,7 @@ DefineTSConfiguration(List *names, List *parameters)
ScanKeyInit ( & skey ,
Anum_pg_ts_config_map_mapcfg ,
BTEqualStrategyNumber , F_OIDEQ ,
ObjectIdGetDatum ( templat eOid) ) ;
ObjectIdGetDatum ( sourc eOid) ) ;
scan = systable_beginscan ( mapRel , TSConfigMapIndexId , true ,
SnapshotNow , 1 , & skey ) ;