fix #490: align vpd policy apply hierarchy

This commit is contained in:
devmrko
2026-06-26 10:26:09 +09:00
parent f39cc49021
commit 9f63adeca5
6 changed files with 170 additions and 31 deletions

View File

@@ -139,6 +139,7 @@ public class VpdPolicyService {
String schemaOwner,
boolean includeTables,
boolean includeViews,
String policyNameValue,
String functionKey,
String functionOwnerValue,
String functionNameValue,
@@ -160,6 +161,9 @@ public class VpdPolicyService {
throw new AppException("선택한 스키마에서 VPD 적용 대상 TABLE/VIEW를 찾을 수 없습니다: " + owner);
}
String bulkPolicyName = policyNameValue == null || policyNameValue.isBlank()
? COMMON_POLICY_NAME
: requiredIdentifier(policyNameValue, "Policy name");
FunctionRef functionRef = parseFunctionRef(defaultFunctionKey(functionKey));
String filterPredicate = filterPredicateValue == null ? "" : filterPredicateValue.trim();
if (functionRef == null && filterPredicate.isBlank()) {
@@ -197,8 +201,7 @@ public class VpdPolicyService {
int skipped = 0;
int failed = 0;
for (VpdSchemaObjectOption target : targets) {
String policyName = generatedPolicyName(target.objectName());
if (mapper.findAnyPolicy(target.owner(), target.objectName(), policyName) != null) {
if (mapper.findAnyPolicy(target.owner(), target.objectName(), bulkPolicyName) != null) {
skipped++;
continue;
}
@@ -206,7 +209,7 @@ public class VpdPolicyService {
addPolicy(
target.owner(),
target.objectName(),
policyName,
bulkPolicyName,
functionOwner,
packageName == null ? functionName : packageName + "." + functionName,
statementTypes,
@@ -538,10 +541,6 @@ public class VpdPolicyService {
return generated.length() > 128 ? generated.substring(0, 128) : generated;
}
private String generatedPolicyName(String objectName) {
return COMMON_POLICY_NAME;
}
private FunctionRef parseFunctionRef(String functionKey) {
if (functionKey == null || functionKey.isBlank()) {
return null;