-1

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.

6 Answers6

0

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.

adil shahid
  • 125
  • 4
-1

Try following may be it work:

  • Insert tuple into two tables simultaneously in ApacheAGE extension.
  • Handle process during earlier stages: parsing, analyzing, planning.
  • Intercept INSERT operation in parsing to detect multi-table insertion.
  • Create custom plan node in planning for simultaneous insertion.
  • Ensure proper tuple insertion into both tables during execution.
  • Avoid modifying TableTupleSlot at execution stage.
  • Provides seamless integration with existing codebase and PostgresAPI.

#Apache-Age #postgresql

saima ali
  • 133
  • 9
-1

Yes, It is possible.

You need to create a custom node in the query tree and make sure that both tables have separate objects for handling the insertion.

-1
  • It is possible to insert a tuple to two tables at the same time in PostgreSQL.
  • Make sure both tables should also have compatible schema structure for insertion without any error.
  • Interception INSERT operation in parsing to detect multi-table insertion and creating a custom node in planning for simultaneous insertion.
  • Finally ensure proper tuple insertion into both tables during execution and avoid modifying TableTupleSort at execution stage.
-1

Certainly, you can insert a tuple or row into two tables simultaneously in PostgreSQL by creating a custom node in the query tree. To ensure this works smoothly, it's crucial that both tables have dedicated mechanisms for handling the insertion process. Additionally, the schema structure of both tables should be compatible to facilitate error-free insertion.

  • This says exactly the same thing (in different words) as the answer just above yours (and probably many of the other answers as well). Please read *all* existing answers before posting a new one. – NotTheDr01ds Sep 02 '23 at 14:58
-3

In order to achieve this, a custom node has to be created in the query tree. Also to ensure smooth execution, you must use separate objects to look after this process. Hope this helps!