LCOV - code coverage report
Current view: top level - src/backend/catalog - objectaccess.c (source / functions) Hit Total Coverage
Test: PostgreSQL 12beta2 Lines: 0 25 0.0 %
Date: 2019-06-19 16:07:09 Functions: 0 5 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-2019, 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_namespace.h"
      15             : #include "catalog/pg_proc.h"
      16             : 
      17             : /*
      18             :  * Hook on object accesses.  This is intended as infrastructure for security
      19             :  * and logging plugins.
      20             :  */
      21             : object_access_hook_type object_access_hook = NULL;
      22             : 
      23             : /*
      24             :  * RunObjectPostCreateHook
      25             :  *
      26             :  * It is entrypoint of OAT_POST_CREATE event
      27             :  */
      28             : void
      29           0 : RunObjectPostCreateHook(Oid classId, Oid objectId, int subId,
      30             :                         bool is_internal)
      31             : {
      32             :     ObjectAccessPostCreate pc_arg;
      33             : 
      34             :     /* caller should check, but just in case... */
      35             :     Assert(object_access_hook != NULL);
      36             : 
      37           0 :     memset(&pc_arg, 0, sizeof(ObjectAccessPostCreate));
      38           0 :     pc_arg.is_internal = is_internal;
      39             : 
      40           0 :     (*object_access_hook) (OAT_POST_CREATE,
      41             :                            classId, objectId, subId,
      42             :                            (void *) &pc_arg);
      43           0 : }
      44             : 
      45             : /*
      46             :  * RunObjectDropHook
      47             :  *
      48             :  * It is entrypoint of OAT_DROP event
      49             :  */
      50             : void
      51           0 : RunObjectDropHook(Oid classId, Oid objectId, int subId,
      52             :                   int dropflags)
      53             : {
      54             :     ObjectAccessDrop drop_arg;
      55             : 
      56             :     /* caller should check, but just in case... */
      57             :     Assert(object_access_hook != NULL);
      58             : 
      59           0 :     memset(&drop_arg, 0, sizeof(ObjectAccessDrop));
      60           0 :     drop_arg.dropflags = dropflags;
      61             : 
      62           0 :     (*object_access_hook) (OAT_DROP,
      63             :                            classId, objectId, subId,
      64             :                            (void *) &drop_arg);
      65           0 : }
      66             : 
      67             : /*
      68             :  * RunObjectPostAlterHook
      69             :  *
      70             :  * It is entrypoint of OAT_POST_ALTER event
      71             :  */
      72             : void
      73           0 : RunObjectPostAlterHook(Oid classId, Oid objectId, int subId,
      74             :                        Oid auxiliaryId, bool is_internal)
      75             : {
      76             :     ObjectAccessPostAlter pa_arg;
      77             : 
      78             :     /* caller should check, but just in case... */
      79             :     Assert(object_access_hook != NULL);
      80             : 
      81           0 :     memset(&pa_arg, 0, sizeof(ObjectAccessPostAlter));
      82           0 :     pa_arg.auxiliary_id = auxiliaryId;
      83           0 :     pa_arg.is_internal = is_internal;
      84             : 
      85           0 :     (*object_access_hook) (OAT_POST_ALTER,
      86             :                            classId, objectId, subId,
      87             :                            (void *) &pa_arg);
      88           0 : }
      89             : 
      90             : /*
      91             :  * RunNamespaceSearchHook
      92             :  *
      93             :  * It is entrypoint of OAT_NAMESPACE_SEARCH event
      94             :  */
      95             : bool
      96           0 : RunNamespaceSearchHook(Oid objectId, bool ereport_on_violation)
      97             : {
      98             :     ObjectAccessNamespaceSearch ns_arg;
      99             : 
     100             :     /* caller should check, but just in case... */
     101             :     Assert(object_access_hook != NULL);
     102             : 
     103           0 :     memset(&ns_arg, 0, sizeof(ObjectAccessNamespaceSearch));
     104           0 :     ns_arg.ereport_on_violation = ereport_on_violation;
     105           0 :     ns_arg.result = true;
     106             : 
     107           0 :     (*object_access_hook) (OAT_NAMESPACE_SEARCH,
     108             :                            NamespaceRelationId, objectId, 0,
     109             :                            (void *) &ns_arg);
     110             : 
     111           0 :     return ns_arg.result;
     112             : }
     113             : 
     114             : /*
     115             :  * RunFunctionExecuteHook
     116             :  *
     117             :  * It is entrypoint of OAT_FUNCTION_EXECUTE event
     118             :  */
     119             : void
     120           0 : RunFunctionExecuteHook(Oid objectId)
     121             : {
     122             :     /* caller should check, but just in case... */
     123             :     Assert(object_access_hook != NULL);
     124             : 
     125           0 :     (*object_access_hook) (OAT_FUNCTION_EXECUTE,
     126             :                            ProcedureRelationId, objectId, 0,
     127             :                            NULL);
     128           0 : }

Generated by: LCOV version 1.13