]> granicus.if.org Git - postgresql/commitdiff
Use TSConfigRelationId in AlterTSConfiguration()
authorStephen Frost <sfrost@snowman.net>
Thu, 22 Dec 2016 22:08:47 +0000 (17:08 -0500)
committerStephen Frost <sfrost@snowman.net>
Thu, 22 Dec 2016 22:08:47 +0000 (17:08 -0500)
When we are altering a text search configuration, we are getting the
tuple from pg_ts_config and using its OID, so use TSConfigRelationId
when invoking any post-alter hooks and setting the object address.

Further, in the functions called from AlterTSConfiguration(), we're
saving information about the command via
EventTriggerCollectAlterTSConfig(), so we should be setting
commandCollected to true.  Also add a regression test to
test_ddl_deparse for ALTER TEXT SEARCH CONFIGURATION.

Author: Artur Zakirov, a few additional comments by me
Discussion: https://www.postgresql.org/message-id/57a71eba-f2c7-e7fd-6fc0-2126ec0b39bd%40postgrespro.ru

Back-patch the fix for the InvokeObjectPostAlterHook() call to 9.3 where
it was introduced, and the fix for the ObjectAddressSet() call and
setting commandCollected to true to 9.5 where those changes to
ProcessUtilitySlow() were introduced.

src/backend/commands/tsearchcmds.c
src/backend/tcop/utility.c
src/test/modules/test_ddl_deparse/Makefile
src/test/modules/test_ddl_deparse/expected/alter_ts_config.out [new file with mode: 0644]
src/test/modules/test_ddl_deparse/sql/alter_ts_config.sql [new file with mode: 0644]

index 69c038c52b15a7f495f04a473b5541e8fd84f185..6bf249bdeaf74a1c902c0c46f15d31c0cfd5ad40 100644 (file)
@@ -1215,10 +1215,10 @@ AlterTSConfiguration(AlterTSConfigurationStmt *stmt)
        /* Update dependencies */
        makeConfigurationDependencies(tup, true, relMap);
 
-       InvokeObjectPostAlterHook(TSConfigMapRelationId,
+       InvokeObjectPostAlterHook(TSConfigRelationId,
                                                          HeapTupleGetOid(tup), 0);
 
-       ObjectAddressSet(address, TSConfigMapRelationId, cfgId);
+       ObjectAddressSet(address, TSConfigRelationId, cfgId);
 
        heap_close(relMap, RowExclusiveLock);
 
index ac50c2a03d18629ace71e3e926dfcf757791fbf8..91021168653cd38cb7053d6e75439ed7cdc5e0c5 100644 (file)
@@ -1467,7 +1467,13 @@ ProcessUtilitySlow(Node *parsetree,
                                break;
 
                        case T_AlterTSConfigurationStmt:
-                               address = AlterTSConfiguration((AlterTSConfigurationStmt *) parsetree);
+                               AlterTSConfiguration((AlterTSConfigurationStmt *) parsetree);
+                               /*
+                                * Commands are stashed in MakeConfigurationMapping and
+                                * DropConfigurationMapping, which are called from
+                                * AlterTSConfiguration
+                                */
+                               commandCollected = true;
                                break;
 
                        case T_AlterTableMoveAllStmt:
index 8ea6f39afd2ca3d42f5a3617ea65901dccf4f4b3..3a57a95c84969e9f22bd7066b79e3191cad2a712 100644 (file)
@@ -23,6 +23,7 @@ REGRESS = test_ddl_deparse \
        comment_on \
        alter_function \
        alter_sequence \
+       alter_ts_config \
        alter_type_enum \
        opfamily \
        defprivs \
diff --git a/src/test/modules/test_ddl_deparse/expected/alter_ts_config.out b/src/test/modules/test_ddl_deparse/expected/alter_ts_config.out
new file mode 100644 (file)
index 0000000..afc352f
--- /dev/null
@@ -0,0 +1,8 @@
+--
+-- ALTER TEXT SEARCH CONFIGURATION
+--
+CREATE TEXT SEARCH CONFIGURATION en (copy=english);
+NOTICE:  DDL test: type simple, tag CREATE TEXT SEARCH CONFIGURATION
+ALTER TEXT SEARCH CONFIGURATION en
+  ALTER MAPPING FOR host, email, url, sfloat WITH simple;
+NOTICE:  DDL test: type alter text search configuration, tag ALTER TEXT SEARCH CONFIGURATION
diff --git a/src/test/modules/test_ddl_deparse/sql/alter_ts_config.sql b/src/test/modules/test_ddl_deparse/sql/alter_ts_config.sql
new file mode 100644 (file)
index 0000000..ac13e21
--- /dev/null
@@ -0,0 +1,8 @@
+--
+-- ALTER TEXT SEARCH CONFIGURATION
+--
+
+CREATE TEXT SEARCH CONFIGURATION en (copy=english);
+
+ALTER TEXT SEARCH CONFIGURATION en
+  ALTER MAPPING FOR host, email, url, sfloat WITH simple;