Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  trigfuncs.c

  Sprache: C
 

/*-------------------------------------------------------------------------
 *
 * trigfuncs.c
 *   Builtin functions for useful trigger support.
 *
 *
 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 * src/backend/utils/adt/trigfuncs.c
 *
 *-------------------------------------------------------------------------
 */

#include "postgres.h"

#include "access/htup_details.h"
#include "commands/trigger.h"
#include "utils/fmgrprotos.h"


/*
 * suppress_redundant_updates_trigger
 *
 * This trigger function will inhibit an update from being done
 * if the OLD and NEW records are identical.
 */

Datum
suppress_redundant_updates_trigger(PG_FUNCTION_ARGS)
{
 TriggerData *trigdata = (TriggerData *) fcinfo->context;
 HeapTuple newtuple,
    oldtuple,
    rettuple;
 HeapTupleHeader newheader,
    oldheader;

 /* make sure it's called as a trigger */
 if (!CALLED_AS_TRIGGER(fcinfo))
  ereport(ERROR,
    (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
     errmsg("suppress_redundant_updates_trigger: must be called as trigger")));

 /* and that it's called on update */
 if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
  ereport(ERROR,
    (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
     errmsg("suppress_redundant_updates_trigger: must be called on update")));

 /* and that it's called before update */
 if (!TRIGGER_FIRED_BEFORE(trigdata->tg_event))
  ereport(ERROR,
    (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
     errmsg("suppress_redundant_updates_trigger: must be called before update")));

 /* and that it's called for each row */
 if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
  ereport(ERROR,
    (errcode(ERRCODE_E_R_I_E_TRIGGER_PROTOCOL_VIOLATED),
     errmsg("suppress_redundant_updates_trigger: must be called for each row")));

 /* get tuple data, set default result */
 rettuple = newtuple = trigdata->tg_newtuple;
 oldtuple = trigdata->tg_trigtuple;

 newheader = newtuple->t_data;
 oldheader = oldtuple->t_data;

 /* if the tuple payload is the same ... */
 if (newtuple->t_len == oldtuple->t_len &&
  newheader->t_hoff == oldheader->t_hoff &&
  (HeapTupleHeaderGetNatts(newheader) ==
   HeapTupleHeaderGetNatts(oldheader)) &&
  ((newheader->t_infomask & ~HEAP_XACT_MASK) ==
   (oldheader->t_infomask & ~HEAP_XACT_MASK)) &&
  memcmp(((char *) newheader) + SizeofHeapTupleHeader,
      ((char *) oldheader) + SizeofHeapTupleHeader,
      newtuple->t_len - SizeofHeapTupleHeader) == 0)
 {
  /* ... then suppress the update */
  rettuple = NULL;
 }

 return PointerGetDatum(rettuple);
}

Messung V0.5 in Prozent
C=94 H=93 G=93

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-08-08) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=141584
#Domains=752002