BUG #17879: ERROR: unrecognized node type: 2139062143 - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #17879: ERROR: unrecognized node type: 2139062143
Date
Msg-id 17879-b7dfb5debee58ff5@postgresql.org
Whole thread Raw
Responses Re: BUG #17879: ERROR: unrecognized node type: 2139062143  (David Rowley <dgrowleyml@gmail.com>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      17879
Logged by:          Fei Changhong
Email address:      feichanghong@qq.com
PostgreSQL version: 15.2
Operating system:   CentOS7 with kernel version 5.10
Description:

We have noticed that an error "ERROR: unrecognized node type:2139062143"
occurs when creating a table with a SEQUENCE column after an event trigger
of type ddl_command_end has already been created. This error can be
reproduced using the following SQL statement, and please note that the
"--enable-cassert" option must be included during configuration.
···
-- CREATE EVENT TRIGGER
CREATE TABLE mytable (id serial primary key, name text);
CREATE OR REPLACE FUNCTION log_ddl_commands() RETURNS event_trigger AS $$
DECLARE
    obj record;
BEGIN
    FOR obj IN SELECT * FROM pg_event_trigger_ddl_commands() WHERE command_tag
<> 'SELECT' LOOP
        RAISE NOTICE 'Command: % Object: %', obj.command_tag,
obj.object_identity;
    END LOOP;
END;
$$ LANGUAGE plpgsql;
CREATE EVENT TRIGGER ddl_log_trigger ON ddl_command_end EXECUTE FUNCTION
log_ddl_commands();
-- Create a table with a SEQUENCE column
CREATE TABLE mytable1(id INT GENERATED ALWAYS AS IDENTITY (SEQUENCE NAME
test_seq));
···

We have identified the root cause as follows: 
In the generateSerialExtraStmts function, the memory space for the seqoption
list has been freed, but the options member of the Constraint still points
to that memory address, which caused an error during the copyObject
operation in the EventTriggerCollectSimpleCommand function.


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: A structure has changed but comment modifications maybe missed
Next
From: David Rowley
Date:
Subject: Re: A structure has changed but comment modifications maybe missed