]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Don't malloc(0) in EventTriggerCollectAlterTSConfig
authorÁlvaro Herrera <alvherre@kurilemu.de>
Wed, 4 Mar 2026 14:04:53 +0000 (15:04 +0100)
committerÁlvaro Herrera <alvherre@kurilemu.de>
Wed, 4 Mar 2026 14:04:53 +0000 (15:04 +0100)
Author: Florin Irion <florin.irion@enterprisedb.com>
Discussion: https://postgr.es/m/c6fff161-9aee-4290-9ada-71e21e4d84de@gmail.com

src/backend/commands/event_trigger.c
src/test/modules/test_ddl_deparse/Makefile
src/test/modules/test_ddl_deparse/expected/textsearch.out [new file with mode: 0644]
src/test/modules/test_ddl_deparse/meson.build
src/test/modules/test_ddl_deparse/sql/textsearch.sql [new file with mode: 0644]

index 028f9e2de9072bb1a11f9553da2e33b8dacebaf3..2898967fa6736a2a816bc0ef7da2e7c5672db835 100644 (file)
@@ -2004,8 +2004,11 @@ EventTriggerCollectAlterTSConfig(AlterTSConfigurationStmt *stmt, Oid cfgId,
        command->in_extension = creating_extension;
        ObjectAddressSet(command->d.atscfg.address,
                                         TSConfigRelationId, cfgId);
-       command->d.atscfg.dictIds = palloc_array(Oid, ndicts);
-       memcpy(command->d.atscfg.dictIds, dictIds, sizeof(Oid) * ndicts);
+       if (ndicts > 0)
+       {
+               command->d.atscfg.dictIds = palloc_array(Oid, ndicts);
+               memcpy(command->d.atscfg.dictIds, dictIds, sizeof(Oid) * ndicts);
+       }
        command->d.atscfg.ndicts = ndicts;
        command->parsetree = (Node *) copyObject(stmt);
 
index 6a9c133ebe970d8673753ea00b67b50531470075..f91a78d8d92bd4b8fb0f78e6047676e64bcbebcb 100644 (file)
@@ -27,6 +27,7 @@ REGRESS = test_ddl_deparse \
        alter_type_enum \
        opfamily \
        defprivs \
+       textsearch \
        matviews
 
 EXTRA_INSTALL = contrib/pg_stat_statements
diff --git a/src/test/modules/test_ddl_deparse/expected/textsearch.out b/src/test/modules/test_ddl_deparse/expected/textsearch.out
new file mode 100644 (file)
index 0000000..da0d89e
--- /dev/null
@@ -0,0 +1,5 @@
+CREATE TEXT SEARCH CONFIGURATION evttrig_tscfg (COPY = pg_catalog.simple);
+NOTICE:  DDL test: type simple, tag CREATE TEXT SEARCH CONFIGURATION
+ALTER TEXT SEARCH CONFIGURATION evttrig_tscfg
+    DROP MAPPING FOR word;
+NOTICE:  DDL test: type alter text search configuration, tag ALTER TEXT SEARCH CONFIGURATION
index 126d81239492dd6e4e077d0bc657760e8d74f46c..85decdf1f2ba38bf665f97b2b5a4f1a17b8da678 100644 (file)
@@ -47,6 +47,7 @@ tests += {
       'alter_type_enum',
       'opfamily',
       'defprivs',
+      'textsearch',
       'matviews',
     ],
   },
diff --git a/src/test/modules/test_ddl_deparse/sql/textsearch.sql b/src/test/modules/test_ddl_deparse/sql/textsearch.sql
new file mode 100644 (file)
index 0000000..633899a
--- /dev/null
@@ -0,0 +1,3 @@
+CREATE TEXT SEARCH CONFIGURATION evttrig_tscfg (COPY = pg_catalog.simple);
+ALTER TEXT SEARCH CONFIGURATION evttrig_tscfg
+    DROP MAPPING FOR word;