機能
秘匿化ポリシーを作成します。
書式
秘匿化種別によって書式が異なります。書式は以下のとおりです。
pgx_create_confidential_policy( [schema_name := 'schema_name',] table_name := 'table_name', policy_name := 'policy_name', expression := 'expression' [, enable := 'policy_status'] [, policy_description := 'policy_description'] [, column_name := 'column_name' [, function_type := 'FULL'] | [, function_type := 'PARTIAL', partial_opt] | [, function_type := 'REGEXP', regexp_opt] [, column_description := 'column_description'] ])
partial_opt: function_parameters := 'masking_format'
regexp_opt: regexp_pattern := 'regexp_pattern', regexp_replacement := 'regexp_replacement', [, regexp_flags := 'regexp_flags']
引数
詳細は以下のとおりです。
| 引数を指定可能な秘匿化種別 | 引数 | データ型 | 意味 | デフォルト値 | 
|---|---|---|---|---|
| すべて | schema_name | varchar(63) | 秘匿化ポリシーを作成するテーブルのスキーマ名 | 'public' | 
| table_name | varchar(63) | 秘匿化ポリシーを作成するテーブル名 | 省略不可 | |
| policy_name | varchar(63) | 秘匿化ポリシー名 | 省略不可 | |
| expression | varchar(1024) | 秘匿化条件 | 省略不可 | |
| enable | boolean | 秘匿化ポリシーの状態 
 | 't' | |
| policy_description | varchar(1024) | 秘匿化ポリシーに関する説明 | NULL | |
| column_name | varchar(63) | 秘匿化対象名 | NULL | |
| function_type | varchar(63) | 秘匿化種別 
 | 'FULL' | |
| column_description | varchar(1024) | 秘匿化対象に関する説明 | NULL | |
| 部分秘匿化 | function_parameters | varchar(1024) | 部分秘匿化の秘匿化形式 | 省略不可 | 
| 正規表現秘匿化 | regexp_pattern | varchar(1024) | 正規表現による改訂方法 | 省略不可 | 
| regexp_replacement | varchar(1024) | 正規表現の改訂後の文字 | 省略不可 | |
| regexp_flags | varchar(20) | 正規表現のフラグ | NULL | 
引数の省略可否は以下のとおりです。
| 引数 | 省略可否 | ||
|---|---|---|---|
| 全秘匿化 | 部分秘匿化 | 正規表現秘匿化 | |
| schema_name | ○ | ○ | ○ | 
| table_name | × | × | × | 
| policy_name | × | × | × | 
| expression | × | × | × | 
| enable | ○ | ○ | ○ | 
| policy_description | ○ | ○ | ○ | 
| column_name | ○ | ○ | ○ | 
| function_type | ○ | ○ | ○ | 
| column_description | ○ | ○ | ○ | 
| function_parameters | - | × | - | 
| regexp_pattern | - | - | × | 
| regexp_replacement | - | - | × | 
| regexp_flags | - | - | ○ | 
○:省略可 ×:省略不可 -:指定した場合は無視されます
戻り値
| 戻り値 | 意味 | 
|---|---|
| TRUE | 正常終了 | 
| FALSE | 異常終了 | 
実行例1
秘匿化対象が含まれない秘匿化ポリシーp1を作成する場合
postgres=# select pgx_create_confidential_policy(table_name := 't1', policy_name := 'p1', expression := '1=1'); pgx_create_confidential_policy --------------------------------- t (1 row)
実行例2
秘匿化種別が全秘匿化である秘匿化対象c1を含む秘匿化ポリシーp1を作成する場合
postgres=# select pgx_create_confidential_policy(schema_name := 'public', table_name := 't1', policy_name := 'p1', expression := '1=1', enable := 't', policy_description := 'this policy is an example.', column_name := 'c1', function_type := 'FULL', column_description := 'c1 column is FULL.'); pgx_create_confidential_policy --------------------------------- t (1 row)
実行例3
秘匿化種別が部分秘匿化である秘匿化対象c2を含む秘匿化ポリシーp1を作成する場合
postgres=# select pgx_create_confidential_policy( table_name := 't1', policy_name := 'p1', expression := '1=1', column_name := 'c2', function_type := 'PARTIAL', function_parameters := 'VVVFVVVVFVVVV, VVV-VVVV-VVVV, *, 4, 11'); pgx_create_confidential_policy --------------------------------- t (1 row)
実行例4
秘匿化種別が正規表現秘匿化である秘匿化対象c3を含む秘匿化ポリシーp1を作成する場合
postgres=# select pgx_create_confidential_policy( table_name := 't1', policy_name := 'p1', expression := '1=1', column_name := 'c3', function_type := 'REGEXP', regexp_pattern := '(.*)(@.*)', regexp_replacement := 'xxx\2', regexp_flags := 'g'); pgx_create_confidential_policy --------------------------------- t (1 row)
説明
pgx_create_confidential_policyシステム管理関数の引数の順序は任意に指定可能です。
column_nameを省略した場合、秘匿化対象が含まれない秘匿化ポリシーのみが作成されます。
各テーブルには1つの秘匿化ポリシーを作成可能です。秘匿化ポリシーに秘匿化対象を追加する場合は、pgx_alter_confidential_policyシステム管理関数で秘匿化対象の追加を行ってください。
function_parametersはfunction_typeがPARTIALの場合に有効です。function_typeがPARTIAL以外の場合は無視されます。
以下の値はfunction_typeがREGEXPの場合に有効です。function_typeがREGEXP以外の場合は無視されます。
regexp_pattern
regexp_replacement
regexp_flags
注意
秘匿化ポリシーを適用するテーブルを削除した場合、秘匿化ポリシーも削除してください
参照
引数に指定する文字列は、“PostgreSQL Documentation”の“String Constants”を参照してください。
regexp_pattern、regexp_replacement、regexp_flagsに指定できる値は、“PostgreSQL Documentation”の“POSIX Regular Expressions”のpattern、replacement、flagsを参照してください。