title: Error while using Trigger in Greenplum
body: <p>If any of you created/tried Triggers on Greenplum, Please help me to resolve this</p>
  
  <p>I have a table where a "id" column has some value, and i want to put a trigger 
  Before insert any data in this table, it should call a function/trigger to check<br/> 
  a) if the data is available for "id" in Parent table or not<br/>
  b) there is already a row available for given "id" </p>
  
  <p>--Table DDL<br/></p>
  
  <pre><code>create table test_trigger(id integer, details text);
  </code></pre>
  
  <p>--Trigger Function<br/></p>
  
  <pre><code>create or replace function insert_row_trigger() returns trigger as $$
  begin
  if exists (SELECT 1 FROM test_trigger WHERE id = NEW.id)
  Then
  Return NULL;
  else
  Return NEW;
  End If;
  End;
  $$ language plpgsql;
  </code></pre>
  
  <p>--Trigger Creation</p>
  
  <pre><code>create trigger my_trigger before insert on test_trigger for each row execute procedure insert_row_trigger();
  </code></pre>
  
  <p>--Drop Trigger</p>
  
  <pre><code>drop trigger my_trigger on test_trigger
  </code></pre>
  
  <p><strong>ERROR</strong></p>
  
  <blockquote>
    <p>ERROR: function cannot execute on segment because it accesses
    relation "jiodba.test_trigger" (functions.c:151) (seg1
    SRDCB0002GPM02:40001 pid=11366) (cdbdisp.c:1477)  DETAIL:  SQL
    statement "SELECT exists (SELECT 1 FROM test_trigger WHERE id = $1 )" 
    PL/pgSQL function "insert_row_trigger" line 2 at if</p>
  </blockquote>
  
  <p>********** Error **********</p>
  
  <blockquote>
    <p>ERROR: function cannot execute on segment because it accesses relation
    "jiodba.test_trigger" (functions.c:151) (seg1 SRDCB0002GPM02:40001
    pid=11366) (cdbdisp.c:1477)  SQL state: XX000  Detail:  SQL statement
    "SELECT exists (SELECT 1 FROM test_trigger WHERE id = $1 )"  PL/pgSQL
    function "insert_row_trigger" line 2 at if</p>
  </blockquote>
  
  <p>Please help me on this.<br/>
   ~I also read somewhere that triggers are not supported in GP</p>