Add OID output argument to DefineTSConfiguration
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 25 Mar 2015 18:57:08 +0000 (15:57 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 25 Mar 2015 18:57:08 +0000 (15:57 -0300)
... which is set to the OID of a copied text search config, whenever the
COPY clause is used.

This is in the spirit of commit a2e35b53c39.

src/backend/commands/tsearchcmds.c
src/backend/tcop/utility.c
src/include/commands/defrem.h

index 45bafd317079c7bb63fa062f1e18f52dbddb6c53..4c404e73d0913a2ea97ed66b1465577e38730081 100644 (file)
@@ -964,7 +964,7 @@ makeConfigurationDependencies(HeapTuple tuple, bool removeOld,
  * CREATE TEXT SEARCH CONFIGURATION
  */
 ObjectAddress
-DefineTSConfiguration(List *names, List *parameters)
+DefineTSConfiguration(List *names, List *parameters, ObjectAddress *copied)
 {
    Relation    cfgRel;
    Relation    mapRel = NULL;
@@ -1013,6 +1013,14 @@ DefineTSConfiguration(List *names, List *parameters)
                (errcode(ERRCODE_SYNTAX_ERROR),
                 errmsg("cannot specify both PARSER and COPY options")));
 
+   /* make copied tsconfig available to callers */
+   if (copied && OidIsValid(sourceOid))
+   {
+       ObjectAddressSet(*copied,
+                        TSConfigRelationId,
+                        sourceOid);
+   }
+
    /*
     * Look up source config if given.
     */
index d9443b1496ad7c372ee8669f9195b85576e363fe..fd09d3ad9ed84950653a0a11966cccfc78ff7215 100644 (file)
@@ -1129,7 +1129,8 @@ ProcessUtilitySlow(Node *parsetree,
                        case OBJECT_TSCONFIGURATION:
                            Assert(stmt->args == NIL);
                            DefineTSConfiguration(stmt->defnames,
-                                                 stmt->definition);
+                                                 stmt->definition,
+                                                 NULL);
                            break;
                        case OBJECT_COLLATION:
                            Assert(stmt->args == NIL);
index a9c67838a63560cdebadfe80749432df9e8d35aa..595f93f79a5b3fee09a74f35571d42179bb90e5a 100644 (file)
@@ -101,7 +101,8 @@ extern ObjectAddress AlterTSDictionary(AlterTSDictionaryStmt *stmt);
 extern ObjectAddress DefineTSTemplate(List *names, List *parameters);
 extern void RemoveTSTemplateById(Oid tmplId);
 
-extern ObjectAddress DefineTSConfiguration(List *names, List *parameters);
+extern ObjectAddress DefineTSConfiguration(List *names, List *parameters,
+                     ObjectAddress *copied);
 extern void RemoveTSConfigurationById(Oid cfgId);
 extern ObjectAddress AlterTSConfiguration(AlterTSConfigurationStmt *stmt);