Thank you for answers.

2016-11-19 21:28 GMT+03:00 Michael Paquier <michael.paqu...@gmail.com>:
> On Thu, Nov 17, 2016 at 1:17 PM, Alvaro Herrera
> <alvhe...@2ndquadrant.com> wrote:
>> It's a bug.  You're right that we need to handle the object class
>> somewhere.  Perhaps I failed to realize that tsconfigs could get
>> altered.
>
> It seems to me that the thing to be careful of here is how a new
> OBJECT_TSCONFIGURATIONMAP should use ObjectAddress. It does not seem
> that complicated, but it needs some work.
> --
> Michael

After some investigation it seems to me that OBJECT_TSCONFIGURATIONMAP
can't be added for pg_ts_config_map. Because this catalog hasn't Oids.

But this bug can be easily fixed (patch attached). I think in
AlterTSConfiguration() TSConfigRelationId should be used instead of
TSConfigMapRelationId. Secondly, in ProcessUtilitySlow() we can use
commandCollected = true. Because configuration entry is added in
EventTriggerCollectAlterTSConfig() into
currentEventTriggerState->commandList.

This patch only fixes the bug. But I think I also can do a patch which
will give pg_ts_config_map entries with
pg_event_trigger_ddl_commands() if someone wants. It can be done using
new entry in the CollectedCommandType structure maybe.

-- 
Artur Zakirov
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index b240113..2b84848 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -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);
 
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index f50ce40..1217d1a 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -1477,7 +1477,8 @@ ProcessUtilitySlow(ParseState *pstate,
 				break;
 
 			case T_AlterTSConfigurationStmt:
-				address = AlterTSConfiguration((AlterTSConfigurationStmt *) parsetree);
+				AlterTSConfiguration((AlterTSConfigurationStmt *) parsetree);
+				commandCollected = true;
 				break;
 
 			case T_AlterTableMoveAllStmt:
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to