Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
f90cc269
Commit
f90cc269
authored
Mar 06, 2013
by
Robert Haas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code beautification for object-access hook machinery.
KaiGai Kohei
parent
f11af2bc
Changes
29
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
123 additions
and
119 deletions
+123
-119
src/backend/catalog/Makefile
src/backend/catalog/Makefile
+2
-1
src/backend/catalog/dependency.c
src/backend/catalog/dependency.c
+2
-8
src/backend/catalog/heap.c
src/backend/catalog/heap.c
+1
-9
src/backend/catalog/index.c
src/backend/catalog/index.c
+2
-9
src/backend/catalog/objectaccess.c
src/backend/catalog/objectaccess.c
+63
-0
src/backend/catalog/pg_collation.c
src/backend/catalog/pg_collation.c
+1
-2
src/backend/catalog/pg_constraint.c
src/backend/catalog/pg_constraint.c
+1
-2
src/backend/catalog/pg_conversion.c
src/backend/catalog/pg_conversion.c
+1
-2
src/backend/catalog/pg_namespace.c
src/backend/catalog/pg_namespace.c
+1
-2
src/backend/catalog/pg_operator.c
src/backend/catalog/pg_operator.c
+2
-4
src/backend/catalog/pg_proc.c
src/backend/catalog/pg_proc.c
+1
-2
src/backend/catalog/pg_type.c
src/backend/catalog/pg_type.c
+2
-4
src/backend/commands/aggregatecmds.c
src/backend/commands/aggregatecmds.c
+1
-0
src/backend/commands/dbcommands.c
src/backend/commands/dbcommands.c
+2
-10
src/backend/commands/event_trigger.c
src/backend/commands/event_trigger.c
+1
-2
src/backend/commands/extension.c
src/backend/commands/extension.c
+1
-2
src/backend/commands/foreigncmds.c
src/backend/commands/foreigncmds.c
+3
-6
src/backend/commands/functioncmds.c
src/backend/commands/functioncmds.c
+1
-2
src/backend/commands/opclasscmds.c
src/backend/commands/opclasscmds.c
+2
-4
src/backend/commands/proclang.c
src/backend/commands/proclang.c
+1
-2
src/backend/commands/tablecmds.c
src/backend/commands/tablecmds.c
+1
-2
src/backend/commands/tablespace.c
src/backend/commands/tablespace.c
+2
-10
src/backend/commands/trigger.c
src/backend/commands/trigger.c
+1
-2
src/backend/commands/tsearchcmds.c
src/backend/commands/tsearchcmds.c
+4
-8
src/backend/commands/user.c
src/backend/commands/user.c
+2
-10
src/backend/rewrite/rewriteDefine.c
src/backend/rewrite/rewriteDefine.c
+1
-2
src/backend/storage/large_object/inv_api.c
src/backend/storage/large_object/inv_api.c
+1
-2
src/backend/utils/init/globals.c
src/backend/utils/init/globals.c
+0
-7
src/include/catalog/objectaccess.h
src/include/catalog/objectaccess.h
+20
-3
No files found.
src/backend/catalog/Makefile
View file @
f90cc269
...
...
@@ -11,7 +11,8 @@ top_builddir = ../../..
include
$(top_builddir)/src/Makefile.global
OBJS
=
catalog.o dependency.o heap.o index.o indexing.o namespace.o aclchk.o
\
objectaddress.o pg_aggregate.o pg_collation.o pg_constraint.o pg_conversion.o
\
objectaccess.o objectaddress.o pg_aggregate.o pg_collation.o
\
pg_constraint.o pg_conversion.o
\
pg_depend.o pg_enum.o pg_inherits.o pg_largeobject.o pg_namespace.o
\
pg_operator.o pg_proc.o pg_range.o pg_db_role_setting.o pg_shdepend.o
\
pg_type.o storage.o toasting.o
...
...
src/backend/catalog/dependency.c
View file @
f90cc269
...
...
@@ -997,14 +997,8 @@ deleteOneObject(const ObjectAddress *object, Relation *depRel, int flags)
HeapTuple
tup
;
/* DROP hook of the objects being removed */
if
(
object_access_hook
)
{
ObjectAccessDrop
drop_arg
;
drop_arg
.
dropflags
=
flags
;
InvokeObjectAccessHook
(
OAT_DROP
,
object
->
classId
,
object
->
objectId
,
object
->
objectSubId
,
&
drop_arg
);
}
InvokeObjectDropHookArg
(
object
->
classId
,
object
->
objectId
,
object
->
objectSubId
,
flags
);
/*
* Close depRel if we are doing a drop concurrently. The object deletion
...
...
src/backend/catalog/heap.c
View file @
f90cc269
...
...
@@ -1293,15 +1293,7 @@ heap_create_with_catalog(const char *relname,
}
/* Post creation hook for new relation */
if
(
object_access_hook
)
{
ObjectAccessPostCreate
post_create_args
;
memset
(
&
post_create_args
,
0
,
sizeof
(
ObjectAccessPostCreate
));
post_create_args
.
is_internal
=
is_internal
;
(
*
object_access_hook
)(
OAT_POST_CREATE
,
RelationRelationId
,
relid
,
0
,
&
post_create_args
);
}
InvokeObjectPostCreateHookArg
(
RelationRelationId
,
relid
,
0
,
is_internal
);
/*
* Store any supplied constraints and defaults.
...
...
src/backend/catalog/index.c
View file @
f90cc269
...
...
@@ -1028,15 +1028,8 @@ index_create(Relation heapRelation,
}
/* Post creation hook for new index */
if
(
object_access_hook
)
{
ObjectAccessPostCreate
post_create_args
;
memset
(
&
post_create_args
,
0
,
sizeof
(
ObjectAccessPostCreate
));
post_create_args
.
is_internal
=
is_internal
;
(
*
object_access_hook
)(
OAT_POST_CREATE
,
RelationRelationId
,
indexRelationId
,
0
,
&
post_create_args
);
}
InvokeObjectPostCreateHookArg
(
RelationRelationId
,
indexRelationId
,
0
,
is_internal
);
/*
* Advance the command counter so that we can see the newly-entered
...
...
src/backend/catalog/objectaccess.c
0 → 100644
View file @
f90cc269
/* -------------------------------------------------------------------------
*
* objectaccess.c
* functions for object_access_hook on various events
*
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* -------------------------------------------------------------------------
*/
#include "postgres.h"
#include "catalog/objectaccess.h"
/*
* Hook on object accesses. This is intended as infrastructure for security
* and logging plugins.
*/
object_access_hook_type
object_access_hook
=
NULL
;
/*
* RunObjectPostCreateHook
*
* It is entrypoint of OAT_POST_CREATE event
*/
void
RunObjectPostCreateHook
(
Oid
classId
,
Oid
objectId
,
int
subId
,
bool
is_internal
)
{
ObjectAccessPostCreate
pc_arg
;
/* caller should check, but just in case... */
Assert
(
object_access_hook
!=
NULL
);
memset
(
&
pc_arg
,
0
,
sizeof
(
ObjectAccessPostCreate
));
pc_arg
.
is_internal
=
is_internal
;
(
*
object_access_hook
)(
OAT_POST_CREATE
,
classId
,
objectId
,
subId
,
(
void
*
)
&
pc_arg
);
}
/*
* RunObjectDropHook
*
* It is entrypoint of OAT_DROP event
*/
void
RunObjectDropHook
(
Oid
classId
,
Oid
objectId
,
int
subId
,
int
dropflags
)
{
ObjectAccessDrop
drop_arg
;
/* caller should check, but just in case... */
Assert
(
object_access_hook
!=
NULL
);
memset
(
&
drop_arg
,
0
,
sizeof
(
ObjectAccessDrop
));
drop_arg
.
dropflags
=
dropflags
;
(
*
object_access_hook
)(
OAT_DROP
,
classId
,
objectId
,
subId
,
(
void
*
)
&
drop_arg
);
}
src/backend/catalog/pg_collation.c
View file @
f90cc269
...
...
@@ -136,8 +136,7 @@ CollationCreate(const char *collname, Oid collnamespace,
recordDependencyOnCurrentExtension
(
&
myself
,
false
);
/* Post creation hook for new collation */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
CollationRelationId
,
oid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
CollationRelationId
,
oid
,
0
);
heap_freetuple
(
tup
);
heap_close
(
rel
,
RowExclusiveLock
);
...
...
src/backend/catalog/pg_constraint.c
View file @
f90cc269
...
...
@@ -367,8 +367,7 @@ CreateConstraintEntry(const char *constraintName,
}
/* Post creation hook for new constraint */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
ConstraintRelationId
,
conOid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
ConstraintRelationId
,
conOid
,
0
);
return
conOid
;
}
...
...
src/backend/catalog/pg_conversion.c
View file @
f90cc269
...
...
@@ -136,8 +136,7 @@ ConversionCreate(const char *conname, Oid connamespace,
recordDependencyOnCurrentExtension
(
&
myself
,
false
);
/* Post creation hook for new conversion */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
ConversionRelationId
,
HeapTupleGetOid
(
tup
),
0
,
NULL
);
InvokeObjectPostCreateHook
(
ConversionRelationId
,
HeapTupleGetOid
(
tup
),
0
);
heap_freetuple
(
tup
);
heap_close
(
rel
,
RowExclusiveLock
);
...
...
src/backend/catalog/pg_namespace.c
View file @
f90cc269
...
...
@@ -96,8 +96,7 @@ NamespaceCreate(const char *nspName, Oid ownerId, bool isTemp)
recordDependencyOnCurrentExtension
(
&
myself
,
false
);
/* Post creation hook for new schema */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
NamespaceRelationId
,
nspoid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
NamespaceRelationId
,
nspoid
,
0
);
return
nspoid
;
}
src/backend/catalog/pg_operator.c
View file @
f90cc269
...
...
@@ -275,8 +275,7 @@ OperatorShellMake(const char *operatorName,
heap_freetuple
(
tup
);
/* Post creation hook for new shell operator */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
OperatorRelationId
,
operatorObjectId
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
OperatorRelationId
,
operatorObjectId
,
0
);
/*
* Make sure the tuple is visible for subsequent lookups/updates.
...
...
@@ -544,8 +543,7 @@ OperatorCreate(const char *operatorName,
makeOperatorDependencies
(
tup
);
/* Post creation hook for new operator */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
OperatorRelationId
,
operatorObjectId
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
OperatorRelationId
,
operatorObjectId
,
0
);
heap_close
(
pg_operator_desc
,
RowExclusiveLock
);
...
...
src/backend/catalog/pg_proc.c
View file @
f90cc269
...
...
@@ -661,8 +661,7 @@ ProcedureCreate(const char *procedureName,
heap_freetuple
(
tup
);
/* Post creation hook for new function */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
ProcedureRelationId
,
retval
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
ProcedureRelationId
,
retval
,
0
);
heap_close
(
rel
,
RowExclusiveLock
);
...
...
src/backend/catalog/pg_type.c
View file @
f90cc269
...
...
@@ -163,8 +163,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
false
);
/* Post creation hook for new shell type */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
TypeRelationId
,
typoid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
TypeRelationId
,
typoid
,
0
);
/*
* clean up and return the type-oid
...
...
@@ -476,8 +475,7 @@ TypeCreate(Oid newTypeOid,
rebuildDeps
);
/* Post creation hook for new type */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
TypeRelationId
,
typeObjectId
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
TypeRelationId
,
typeObjectId
,
0
);
/*
* finish up
...
...
src/backend/commands/aggregatecmds.c
View file @
f90cc269
...
...
@@ -29,6 +29,7 @@
#include "catalog/pg_aggregate.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "commands/alter.h"
#include "commands/defrem.h"
#include "miscadmin.h"
#include "parser/parse_func.h"
...
...
src/backend/commands/dbcommands.c
View file @
f90cc269
...
...
@@ -524,8 +524,7 @@ createdb(const CreatedbStmt *stmt)
copyTemplateDependencies
(
src_dboid
,
dboid
);
/* Post creation hook for new database */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
DatabaseRelationId
,
dboid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
DatabaseRelationId
,
dboid
,
0
);
/*
* Force a checkpoint before starting the copy. This will force dirty
...
...
@@ -816,14 +815,7 @@ dropdb(const char *dbname, bool missing_ok)
dbname
);
/* DROP hook for the database being removed */
if
(
object_access_hook
)
{
ObjectAccessDrop
drop_arg
;
memset
(
&
drop_arg
,
0
,
sizeof
(
ObjectAccessDrop
));
InvokeObjectAccessHook
(
OAT_DROP
,
DatabaseRelationId
,
db_id
,
0
,
&
drop_arg
);
}
InvokeObjectDropHook
(
DatabaseRelationId
,
db_id
,
0
);
/*
* Disallow dropping a DB that is marked istemplate. This is just to
...
...
src/backend/commands/event_trigger.c
View file @
f90cc269
...
...
@@ -310,8 +310,7 @@ insert_event_trigger_tuple(char *trigname, char *eventname, Oid evtOwner,
recordDependencyOn
(
&
myself
,
&
referenced
,
DEPENDENCY_NORMAL
);
/* Post creation hook for new operator family */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
EventTriggerRelationId
,
trigoid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
EventTriggerRelationId
,
trigoid
,
0
);
/* Close pg_event_trigger. */
heap_close
(
tgrel
,
RowExclusiveLock
);
...
...
src/backend/commands/extension.c
View file @
f90cc269
...
...
@@ -1562,8 +1562,7 @@ InsertExtensionTuple(const char *extName, Oid extOwner,
recordDependencyOn
(
&
myself
,
&
otherext
,
DEPENDENCY_NORMAL
);
}
/* Post creation hook for new extension */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
ExtensionRelationId
,
extensionOid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
ExtensionRelationId
,
extensionOid
,
0
);
return
extensionOid
;
}
...
...
src/backend/commands/foreigncmds.c
View file @
f90cc269
...
...
@@ -599,8 +599,7 @@ CreateForeignDataWrapper(CreateFdwStmt *stmt)
recordDependencyOnCurrentExtension
(
&
myself
,
false
);
/* Post creation hook for new foreign data wrapper */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
ForeignDataWrapperRelationId
,
fdwId
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
ForeignDataWrapperRelationId
,
fdwId
,
0
);
heap_close
(
rel
,
RowExclusiveLock
);
...
...
@@ -900,8 +899,7 @@ CreateForeignServer(CreateForeignServerStmt *stmt)
recordDependencyOnCurrentExtension
(
&
myself
,
false
);
/* Post creation hook for new foreign server */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
ForeignServerRelationId
,
srvId
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
ForeignServerRelationId
,
srvId
,
0
);
heap_close
(
rel
,
RowExclusiveLock
);
...
...
@@ -1145,8 +1143,7 @@ CreateUserMapping(CreateUserMappingStmt *stmt)
recordDependencyOnCurrentExtension
(
&
myself
,
false
);
/* Post creation hook for new user mapping */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
UserMappingRelationId
,
umId
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
UserMappingRelationId
,
umId
,
0
);
heap_close
(
rel
,
RowExclusiveLock
);
...
...
src/backend/commands/functioncmds.c
View file @
f90cc269
...
...
@@ -1558,8 +1558,7 @@ CreateCast(CreateCastStmt *stmt)
recordDependencyOnCurrentExtension
(
&
myself
,
false
);
/* Post creation hook for new cast */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
CastRelationId
,
castid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
CastRelationId
,
castid
,
0
);
heap_freetuple
(
tuple
);
...
...
src/backend/commands/opclasscmds.c
View file @
f90cc269
...
...
@@ -309,8 +309,7 @@ CreateOpFamily(char *amname, char *opfname, Oid namespaceoid, Oid amoid)
recordDependencyOnCurrentExtension
(
&
myself
,
false
);
/* Post creation hook for new operator family */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
OperatorFamilyRelationId
,
opfamilyoid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
OperatorFamilyRelationId
,
opfamilyoid
,
0
);
heap_close
(
rel
,
RowExclusiveLock
);
...
...
@@ -710,8 +709,7 @@ DefineOpClass(CreateOpClassStmt *stmt)
recordDependencyOnCurrentExtension
(
&
myself
,
false
);
/* Post creation hook for new operator class */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
OperatorClassRelationId
,
opclassoid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
OperatorClassRelationId
,
opclassoid
,
0
);
heap_close
(
rel
,
RowExclusiveLock
);
...
...
src/backend/commands/proclang.c
View file @
f90cc269
...
...
@@ -429,8 +429,7 @@ create_proc_lang(const char *languageName, bool replace,
}
/* Post creation hook for new procedural language */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
LanguageRelationId
,
myself
.
objectId
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
LanguageRelationId
,
myself
.
objectId
,
0
);
heap_close
(
rel
,
RowExclusiveLock
);
...
...
src/backend/commands/tablecmds.c
View file @
f90cc269
...
...
@@ -4514,8 +4514,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
heap_freetuple
(
reltup
);
/* Post creation hook for new attribute */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
RelationRelationId
,
myrelid
,
newattnum
,
NULL
);
InvokeObjectPostCreateHook
(
RelationRelationId
,
myrelid
,
newattnum
);
heap_close
(
pgclass
,
RowExclusiveLock
);
...
...
src/backend/commands/tablespace.c
View file @
f90cc269
...
...
@@ -331,8 +331,7 @@ CreateTableSpace(CreateTableSpaceStmt *stmt)
recordDependencyOnOwner
(
TableSpaceRelationId
,
tablespaceoid
,
ownerId
);
/* Post creation hook for new tablespace */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
TableSpaceRelationId
,
tablespaceoid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
TableSpaceRelationId
,
tablespaceoid
,
0
);
create_tablespace_directories
(
location
,
tablespaceoid
);
...
...
@@ -439,14 +438,7 @@ DropTableSpace(DropTableSpaceStmt *stmt)
tablespacename
);
/* DROP hook for the tablespace being removed */
if
(
object_access_hook
)
{
ObjectAccessDrop
drop_arg
;
memset
(
&
drop_arg
,
0
,
sizeof
(
ObjectAccessDrop
));
InvokeObjectAccessHook
(
OAT_DROP
,
TableSpaceRelationId
,
tablespaceoid
,
0
,
&
drop_arg
);
}
InvokeObjectDropHook
(
TableSpaceRelationId
,
tablespaceoid
,
0
);
/*
* Remove the pg_tablespace tuple (this will roll back if we fail below)
...
...
src/backend/commands/trigger.c
View file @
f90cc269
...
...
@@ -742,8 +742,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
DEPENDENCY_NORMAL
);
/* Post creation hook for new trigger */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
TriggerRelationId
,
trigoid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
TriggerRelationId
,
trigoid
,
0
);
/* Keep lock on target rel until end of xact */
heap_close
(
rel
,
NoLock
);
...
...
src/backend/commands/tsearchcmds.c
View file @
f90cc269
...
...
@@ -272,8 +272,7 @@ DefineTSParser(List *names, List *parameters)
makeParserDependencies
(
tup
);
/* Post creation hook for new text search parser */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
TSParserRelationId
,
prsOid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
TSParserRelationId
,
prsOid
,
0
);
heap_freetuple
(
tup
);
...
...
@@ -479,8 +478,7 @@ DefineTSDictionary(List *names, List *parameters)
makeDictionaryDependencies
(
tup
);
/* Post creation hook for new text search dictionary */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
TSDictionaryRelationId
,
dictOid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
TSDictionaryRelationId
,
dictOid
,
0
);
heap_freetuple
(
tup
);
...
...
@@ -796,8 +794,7 @@ DefineTSTemplate(List *names, List *parameters)
makeTSTemplateDependencies
(
tup
);
/* Post creation hook for new text search template */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
TSTemplateRelationId
,
tmplOid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
TSTemplateRelationId
,
tmplOid
,
0
);
heap_freetuple
(
tup
);
...
...
@@ -1092,8 +1089,7 @@ DefineTSConfiguration(List *names, List *parameters)
makeConfigurationDependencies
(
tup
,
false
,
mapRel
);
/* Post creation hook for new text search configuration */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
TSConfigRelationId
,
cfgOid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
TSConfigRelationId
,
cfgOid
,
0
);
heap_freetuple
(
tup
);
...
...
src/backend/commands/user.c
View file @
f90cc269
...
...
@@ -426,8 +426,7 @@ CreateRole(CreateRoleStmt *stmt)
GetUserId
(),
false
);
/* Post creation hook for new role */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
AuthIdRelationId
,
roleid
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
AuthIdRelationId
,
roleid
,
0
);
/*
* Close pg_authid, but keep lock till commit.
...
...
@@ -968,14 +967,7 @@ DropRole(DropRoleStmt *stmt)
errmsg
(
"must be superuser to drop superusers"
)));
/* DROP hook for the role being removed */
if
(
object_access_hook
)
{
ObjectAccessDrop
drop_arg
;
memset
(
&
drop_arg
,
0
,
sizeof
(
ObjectAccessDrop
));
InvokeObjectAccessHook
(
OAT_DROP
,
AuthIdRelationId
,
roleid
,
0
,
&
drop_arg
);
}
InvokeObjectDropHook
(
AuthIdRelationId
,
roleid
,
0
);
/*
* Lock the role, so nobody can add dependencies to her while we drop
...
...
src/backend/rewrite/rewriteDefine.c
View file @
f90cc269
...
...
@@ -182,8 +182,7 @@ InsertRule(char *rulname,
}
/* Post creation hook for new rule */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
RewriteRelationId
,
rewriteObjectId
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
RewriteRelationId
,
rewriteObjectId
,
0
);
heap_close
(
pg_rewrite_desc
,
RowExclusiveLock
);
...
...
src/backend/storage/large_object/inv_api.c
View file @
f90cc269
...
...
@@ -218,8 +218,7 @@ inv_create(Oid lobjId)
lobjId_new
,
GetUserId
());
/* Post creation hook for new large object */
InvokeObjectAccessHook
(
OAT_POST_CREATE
,
LargeObjectRelationId
,
lobjId_new
,
0
,
NULL
);
InvokeObjectPostCreateHook
(
LargeObjectRelationId
,
lobjId_new
,
0
);
/*
* Advance command counter to make new tuple visible to later operations.
...
...
src/backend/utils/init/globals.c
View file @
f90cc269
...
...
@@ -18,7 +18,6 @@
*/
#include "postgres.h"
#include "catalog/objectaccess.h"
#include "libpq/pqcomm.h"
#include "miscadmin.h"
#include "storage/backendid.h"
...
...
@@ -126,9 +125,3 @@ int VacuumCostBalance = 0; /* working state for vacuum */
bool
VacuumCostActive
=
false
;
int
GinFuzzySearchLimit
=
0
;
/*
* Hook on object accesses. This is intended as infrastructure for security
* and logging plugins.
*/
object_access_hook_type
object_access_hook
=
NULL
;
src/include/catalog/objectaccess.h
View file @
f90cc269
...
...
@@ -28,6 +28,7 @@ typedef enum ObjectAccessType
{
OAT_POST_CREATE
,
OAT_DROP
,
OAT_POST_ALTER
,
}
ObjectAccessType
;
/*
...
...
@@ -66,11 +67,27 @@ typedef void (*object_access_hook_type) (ObjectAccessType access,
extern
PGDLLIMPORT
object_access_hook_type
object_access_hook
;
#define InvokeObjectAccessHook(access,classId,objectId,subId,arg) \
extern
void
RunObjectPostCreateHook
(
Oid
classId
,
Oid
objectId
,
int
subId
,
bool
is_internal
);
extern
void
RunObjectDropHook
(
Oid
classId
,
Oid
objectId
,
int
subId
,
int
dropflags
);
#define InvokeObjectPostCreateHook(classId,objectId,subId) \
InvokeObjectPostCreateHookArg((classId),(objectId),(subId),false)
#define InvokeObjectPostCreateHookArg(classId,objectId,subId,is_internal) \
do { \
if (object_access_hook) \
RunObjectPostCreateHook((classId),(objectId),(subId), \
(is_internal)); \
} while(0)
#define InvokeObjectDropHook(classId,objectId,subId) \
InvokeObjectDropHookArg((classId),(objectId),(subId),0)
#define InvokeObjectDropHookArg(classId,objectId,subId,dropflags) \
do { \
if (object_access_hook) \
(*object_access_hook)((access),(classId),
\
(objectId),(subId),(arg));
\
RunObjectDropHook((classId),(objectId),(subId),
\
(dropflags));
\
} while(0)
#endif
/* OBJECTACCESS_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment