Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcc1ed40

Browse files
committed
Object access hook framework, with post-creation hook.
After a SQL object is created, we provide an opportunity for securityor logging plugins to get control; for example, a security label providercould use this to assign an initial security label to newly createdobjects. The basic infrastructure is (hopefully) reusable for other typesof events that might require similar treatment.KaiGai Kohei, with minor adjustments.
1 parentd3c1265 commitcc1ed40

File tree

21 files changed

+167
-0
lines changed

21 files changed

+167
-0
lines changed

‎src/backend/catalog/heap.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include"catalog/index.h"
4141
#include"catalog/indexing.h"
4242
#include"catalog/namespace.h"
43+
#include"catalog/objectaccess.h"
4344
#include"catalog/pg_attrdef.h"
4445
#include"catalog/pg_constraint.h"
4546
#include"catalog/pg_inherits.h"
@@ -1188,6 +1189,9 @@ heap_create_with_catalog(const char *relname,
11881189
}
11891190
}
11901191

1192+
/* Post creation hook for new relation */
1193+
InvokeObjectAccessHook(OAT_POST_CREATE,RelationRelationId,relid,0);
1194+
11911195
/*
11921196
* Store any supplied constraints and defaults.
11931197
*

‎src/backend/catalog/pg_constraint.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include"access/heapam.h"
1919
#include"catalog/dependency.h"
2020
#include"catalog/indexing.h"
21+
#include"catalog/objectaccess.h"
2122
#include"catalog/pg_constraint.h"
2223
#include"catalog/pg_operator.h"
2324
#include"catalog/pg_type.h"
@@ -360,6 +361,9 @@ CreateConstraintEntry(const char *constraintName,
360361
DEPENDENCY_NORMAL);
361362
}
362363

364+
/* Post creation hook for new constraint */
365+
InvokeObjectAccessHook(OAT_POST_CREATE,ConstraintRelationId,conOid,0);
366+
363367
returnconOid;
364368
}
365369

‎src/backend/catalog/pg_conversion.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include"access/sysattr.h"
1919
#include"catalog/dependency.h"
2020
#include"catalog/indexing.h"
21+
#include"catalog/objectaccess.h"
2122
#include"catalog/pg_conversion.h"
2223
#include"catalog/pg_conversion_fn.h"
2324
#include"catalog/pg_namespace.h"
@@ -131,6 +132,10 @@ ConversionCreate(const char *conname, Oid connamespace,
131132
recordDependencyOnOwner(ConversionRelationId,HeapTupleGetOid(tup),
132133
conowner);
133134

135+
/* Post creation hook for new conversion */
136+
InvokeObjectAccessHook(OAT_POST_CREATE,
137+
ConversionRelationId,HeapTupleGetOid(tup),0);
138+
134139
heap_freetuple(tup);
135140
heap_close(rel,RowExclusiveLock);
136141

‎src/backend/catalog/pg_namespace.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include"access/heapam.h"
1818
#include"catalog/dependency.h"
1919
#include"catalog/indexing.h"
20+
#include"catalog/objectaccess.h"
2021
#include"catalog/pg_namespace.h"
2122
#include"utils/builtins.h"
2223
#include"utils/rel.h"
@@ -75,5 +76,8 @@ NamespaceCreate(const char *nspName, Oid ownerId)
7576
/* Record dependency on owner */
7677
recordDependencyOnOwner(NamespaceRelationId,nspoid,ownerId);
7778

79+
/* Post creation hook for new schema */
80+
InvokeObjectAccessHook(OAT_POST_CREATE,NamespaceRelationId,nspoid,0);
81+
7882
returnnspoid;
7983
}

‎src/backend/catalog/pg_operator.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include"catalog/dependency.h"
2323
#include"catalog/indexing.h"
2424
#include"catalog/namespace.h"
25+
#include"catalog/objectaccess.h"
2526
#include"catalog/pg_namespace.h"
2627
#include"catalog/pg_operator.h"
2728
#include"catalog/pg_proc.h"
@@ -273,6 +274,10 @@ OperatorShellMake(const char *operatorName,
273274

274275
heap_freetuple(tup);
275276

277+
/* Post creation hook for new shell operator */
278+
InvokeObjectAccessHook(OAT_POST_CREATE,
279+
OperatorRelationId,operatorObjectId,0);
280+
276281
/*
277282
* Make sure the tuple is visible for subsequent lookups/updates.
278283
*/
@@ -539,6 +544,10 @@ OperatorCreate(const char *operatorName,
539544
/* Add dependencies for the entry */
540545
makeOperatorDependencies(tup);
541546

547+
/* Post creation hook for new operator */
548+
InvokeObjectAccessHook(OAT_POST_CREATE,
549+
OperatorRelationId,operatorObjectId,0);
550+
542551
heap_close(pg_operator_desc,RowExclusiveLock);
543552

544553
/*

‎src/backend/catalog/pg_proc.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include"access/xact.h"
1919
#include"catalog/dependency.h"
2020
#include"catalog/indexing.h"
21+
#include"catalog/objectaccess.h"
2122
#include"catalog/pg_language.h"
2223
#include"catalog/pg_namespace.h"
2324
#include"catalog/pg_proc.h"
@@ -616,6 +617,9 @@ ProcedureCreate(const char *procedureName,
616617

617618
heap_freetuple(tup);
618619

620+
/* Post creation hook for new function */
621+
InvokeObjectAccessHook(OAT_POST_CREATE,ProcedureRelationId,retval,0);
622+
619623
heap_close(rel,RowExclusiveLock);
620624

621625
/* Verify function body */

‎src/backend/catalog/pg_type.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include"access/xact.h"
1919
#include"catalog/dependency.h"
2020
#include"catalog/indexing.h"
21+
#include"catalog/objectaccess.h"
2122
#include"catalog/pg_namespace.h"
2223
#include"catalog/pg_proc.h"
2324
#include"catalog/pg_type.h"
@@ -155,6 +156,9 @@ TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
155156
NULL,
156157
false);
157158

159+
/* Post creation hook for new shell type */
160+
InvokeObjectAccessHook(OAT_POST_CREATE,TypeRelationId,typoid,0);
161+
158162
/*
159163
* clean up and return the type-oid
160164
*/
@@ -455,6 +459,9 @@ TypeCreate(Oid newTypeOid,
455459
NULL),
456460
rebuildDeps);
457461

462+
/* Post creation hook for new type */
463+
InvokeObjectAccessHook(OAT_POST_CREATE,TypeRelationId,typeObjectId,0);
464+
458465
/*
459466
* finish up
460467
*/

‎src/backend/commands/dbcommands.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include"catalog/catalog.h"
3333
#include"catalog/dependency.h"
3434
#include"catalog/indexing.h"
35+
#include"catalog/objectaccess.h"
3536
#include"catalog/pg_authid.h"
3637
#include"catalog/pg_database.h"
3738
#include"catalog/pg_db_role_setting.h"
@@ -572,6 +573,9 @@ createdb(const CreatedbStmt *stmt)
572573
/* Create pg_shdepend entries for objects within database */
573574
copyTemplateDependencies(src_dboid,dboid);
574575

576+
/* Post creation hook for new database */
577+
InvokeObjectAccessHook(OAT_POST_CREATE,DatabaseRelationId,dboid,0);
578+
575579
/*
576580
* Force a checkpoint before starting the copy. This will force dirty
577581
* buffers out to disk, to ensure source database is up-to-date on disk

‎src/backend/commands/foreigncmds.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include"catalog/catalog.h"
1919
#include"catalog/dependency.h"
2020
#include"catalog/indexing.h"
21+
#include"catalog/objectaccess.h"
2122
#include"catalog/pg_foreign_data_wrapper.h"
2223
#include"catalog/pg_foreign_server.h"
2324
#include"catalog/pg_proc.h"
@@ -415,6 +416,10 @@ CreateForeignDataWrapper(CreateFdwStmt *stmt)
415416

416417
recordDependencyOnOwner(ForeignDataWrapperRelationId,fdwId,ownerId);
417418

419+
/* Post creation hook for new foreign data wrapper */
420+
InvokeObjectAccessHook(OAT_POST_CREATE,
421+
ForeignDataWrapperRelationId,fdwId,0);
422+
418423
heap_close(rel,NoLock);
419424
}
420425

@@ -696,6 +701,9 @@ CreateForeignServer(CreateForeignServerStmt *stmt)
696701

697702
recordDependencyOnOwner(ForeignServerRelationId,srvId,ownerId);
698703

704+
/* Post creation hook for new foreign server */
705+
InvokeObjectAccessHook(OAT_POST_CREATE,ForeignServerRelationId,srvId,0);
706+
699707
heap_close(rel,NoLock);
700708
}
701709

@@ -967,6 +975,9 @@ CreateUserMapping(CreateUserMappingStmt *stmt)
967975
/* Record the mapped user dependency */
968976
recordDependencyOnOwner(UserMappingRelationId,umId,useId);
969977

978+
/* Post creation hook for new user mapping */
979+
InvokeObjectAccessHook(OAT_POST_CREATE,UserMappingRelationId,umId,0);
980+
970981
heap_close(rel,NoLock);
971982
}
972983

‎src/backend/commands/functioncmds.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include"access/sysattr.h"
3838
#include"catalog/dependency.h"
3939
#include"catalog/indexing.h"
40+
#include"catalog/objectaccess.h"
4041
#include"catalog/pg_aggregate.h"
4142
#include"catalog/pg_cast.h"
4243
#include"catalog/pg_language.h"
@@ -1761,6 +1762,10 @@ CreateCast(CreateCastStmt *stmt)
17611762
recordDependencyOn(&myself,&referenced,DEPENDENCY_NORMAL);
17621763
}
17631764

1765+
/* Post creation hook for new cast */
1766+
InvokeObjectAccessHook(OAT_POST_CREATE,
1767+
CastRelationId,myself.objectId,0);
1768+
17641769
heap_freetuple(tuple);
17651770

17661771
heap_close(relation,RowExclusiveLock);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp