LCOV - code coverage report
Current view: top level - src/backend/catalog - objectaccess.c (source / functions) Hit Total Coverage
Test: PostgreSQL 13beta1 Lines: 0 28 0.0 %
Date: 2020-06-05 19:06:29 Functions: 0 6 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -------------------------------------------------------------------------
       2             :  *
       3             :  * objectaccess.c
       4             :  *      functions for object_access_hook on various events
       5             :  *
       6             :  * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
       7             :  * Portions Copyright (c) 1994, Regents of the University of California
       8             :  *
       9             :  * -------------------------------------------------------------------------
      10             :  */
      11             : #include "postgres.h"
      12             : 
      13             : #include "catalog/objectaccess.h"
      14             : #include "catalog/pg_class.h"
      15             : #include "catalog/pg_namespace.h"
      16             : #include "catalog/pg_proc.h"
      17             : 
      18             : /*
      19             :  * Hook on object accesses.  This is intended as infrastructure for security
      20             :  * and logging plugins.
      21             :  */
      22             : object_access_hook_type object_access_hook = NULL;
      23             : 
      24             : /*
      25             :  * RunObjectPostCreateHook
      26             :  *
      27             :  * It is entrypoint of OAT_POST_CREATE event
      28             :  */
      29             : void
      30           0 : RunObjectPostCreateHook(Oid classId, Oid objectId, int subId,
      31             :                         bool is_internal)
      32             : {
      33             :     ObjectAccessPostCreate pc_arg;
      34             : 
      35             :     /* caller should check, but just in case... */
      36             :     Assert(object_access_hook != NULL);
      37             : 
      38           0 :     memset(&pc_arg, 0, sizeof(ObjectAccessPostCreate));
      39           0 :     pc_arg.is_internal = is_internal;
      40             : 
      41           0 :     (*object_access_hook) (OAT_POST_CREATE,
      42             :                            classId, objectId, subId,
      43             :                            (void *) &pc_arg);
      44           0 : }
      45             : 
      46             : /*
      47             :  * RunObjectDropHook
      48             :  *
      49             :  * It is entrypoint of OAT_DROP event
      50             :  */
      51             : void
      52           0 : RunObjectDropHook(Oid classId, Oid objectId, int subId,
      53             :                   int dropflags)
      54             : {
      55             :     ObjectAccessDrop drop_arg;
      56             : 
      57             :     /* caller should check, but just in case... */
      58             :     Assert(object_access_hook != NULL);
      59             : 
      60           0 :     memset(&drop_arg, 0, sizeof(ObjectAccessDrop));
      61           0 :     drop_arg.dropflags = dropflags;
      62             : 
      63           0 :     (*object_access_hook) (OAT_DROP,
      64             :                            classId, objectId, subId,
      65             :                            (void *) &drop_arg);
      66           0 : }
      67             : 
      68             : /*
      69             :  * RunObjectTruncateHook
      70             :  *
      71             :  * It is the entrypoint of OAT_TRUNCATE event
      72             :  */
      73             : void
      74           0 : RunObjectTruncateHook(Oid objectId)
      75             : {
      76             :     /* caller should check, but just in case... */
      77             :     Assert(object_access_hook != NULL);
      78             : 
      79           0 :     (*object_access_hook) (OAT_TRUNCATE,
      80             :                            RelationRelationId, objectId, 0,
      81             :                            NULL);
      82           0 : }
      83             : 
      84             : /*
      85             :  * RunObjectPostAlterHook
      86             :  *
      87             :  * It is entrypoint of OAT_POST_ALTER event
      88             :  */
      89             : void
      90           0 : RunObjectPostAlterHook(Oid classId, Oid objectId, int subId,
      91             :                        Oid auxiliaryId, bool is_internal)
      92             : {
      93             :     ObjectAccessPostAlter pa_arg;
      94             : 
      95             :     /* caller should check, but just in case... */
      96             :     Assert(object_access_hook != NULL);
      97             : 
      98           0 :     memset(&pa_arg, 0, sizeof(ObjectAccessPostAlter));
      99           0 :     pa_arg.auxiliary_id = auxiliaryId;
     100           0 :     pa_arg.is_internal = is_internal;
     101             : 
     102           0 :     (*object_access_hook) (OAT_POST_ALTER,
     103             :                            classId, objectId, subId,
     104             :                            (void *) &pa_arg);
     105           0 : }
     106             : 
     107             : /*
     108             :  * RunNamespaceSearchHook
     109             :  *
     110             :  * It is entrypoint of OAT_NAMESPACE_SEARCH event
     111             :  */
     112             : bool
     113           0 : RunNamespaceSearchHook(Oid objectId, bool ereport_on_violation)
     114             : {
     115             :     ObjectAccessNamespaceSearch ns_arg;
     116             : 
     117             :     /* caller should check, but just in case... */
     118             :     Assert(object_access_hook != NULL);
     119             : 
     120           0 :     memset(&ns_arg, 0, sizeof(ObjectAccessNamespaceSearch));
     121           0 :     ns_arg.ereport_on_violation = ereport_on_violation;
     122           0 :     ns_arg.result = true;
     123             : 
     124           0 :     (*object_access_hook) (OAT_NAMESPACE_SEARCH,
     125             :                            NamespaceRelationId, objectId, 0,
     126             :                            (void *) &ns_arg);
     127             : 
     128           0 :     return ns_arg.result;
     129             : }
     130             : 
     131             : /*
     132             :  * RunFunctionExecuteHook
     133             :  *
     134             :  * It is entrypoint of OAT_FUNCTION_EXECUTE event
     135             :  */
     136             : void
     137           0 : RunFunctionExecuteHook(Oid objectId)
     138             : {
     139             :     /* caller should check, but just in case... */
     140             :     Assert(object_access_hook != NULL);
     141             : 
     142           0 :     (*object_access_hook) (OAT_FUNCTION_EXECUTE,
     143             :                            ProcedureRelationId, objectId, 0,
     144             :                            NULL);
     145           0 : }

Generated by: LCOV version 1.13