Im developing a feature for the apacheAGE extension and basically I want to insert a tuple to two tables at the same time. I know that Postgres provides the inheritance system, so you can access the tuples from the parent table and the child table. In my case, I want the tuple to actually be inserted in two tables.
I thought about adding another table_tuple_insert()
at the executioner stage, after I’ve constructed my own ResultRelInfo
, but from my understanding a TableTupleSlot
struct holds important information about the table that will be inserted including the number of attributes of the table, so I can’t just copy and use the same TableTupleSlot
.
So my question is, is there a way to make it work at the executioner stage and insert it there, by modifying to an extent the TableTupleSlot
, or is it something more complicated that should be handled at the earlier stages of parsing/analyzing/planning etc.? All of these changes won’t be made directly at the postgresAPI of course, there will take place in the apacheAGE code.
2
Answers
Try following may be it work:
insertion.
#Apache-Age #postgresql
Yes, you can insert a tuple/row in two tables simultaneously in postgresql. You need to create a custom node in the query tree
Make sure that both tables have separate objects for handling the insertion. And both the tables should also have compatible schema structure for insertion without any error.