Altering the SELECT portion of a CREATE TABLE AS plan - Mailing list pgsql-hackers

From Jerry Sievert
Subject Altering the SELECT portion of a CREATE TABLE AS plan
Date
Msg-id EC42A100-0ADA-4051-A0EC-DDB08AD597AB@legitimatesounding.com
Whole thread Raw
List pgsql-hackers
Hi, i am trying to mutate a plan for a T_CreateTableAsStmt before it executes.

I've created a planner_hook_type hook, where i can see the plan that gets executed as part of the AS of the query,
wherethe CmdType is CMD_SELECT, and its subplans are the plans for the actual select itself. 

I've also created a ProcessUtility_hook_type, which correctly shows the T_CreateTableAsStmt, but the hook is called
afterthe actual CREATE TABLE is called, and the plan is no longer mutable for the part that i need. 

Is there another hook i should be looking at, or another way i should be approaching this?  I need to be able to alter
theplan specifically for the SELECT portion of a CREATE TABLE AS query, but only in the case of the SELECT TABLE AS,
andin no other SELECTs. 

Alternately, I can look at the query string in the CMD_SELECT planner hook and search specifically for CREATE, TABLE
andAS, but I feel that there has to be a better way, and look forward to some guidance. 

Thanks!


pgsql-hackers by date:

Previous
From: Chapman Flack
Date:
Subject: Re: PostgreSQL 16 release announcement draft
Next
From: Nathan Bossart
Date:
Subject: Re: pg_stat_get_backend_subxact() and backend IDs?