skip to Main Content

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


  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

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search