Skip to content
This repository was archived by the owner on Nov 14, 2020. It is now read-only.

Commit 647365a

Browse files
committed
add read for log_statement
1 parent d7918bb commit 647365a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

postgresql/resource_postgresql_role.go

+14
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ func resourcePostgreSQLRoleReadImpl(c *Client, d *schema.ResourceData) error {
464464
d.Set(roleReplicationAttr, roleBypassRLS)
465465
d.Set(roleRolesAttr, pgArrayToSet(roleRoles))
466466
d.Set(roleSearchPathAttr, readSearchPath(roleConfig))
467+
d.Set(roleLogStatementAttr, readLogStatement(roleConfig))
467468

468469
statementTimeout, err := readStatementTimeout(roleConfig)
469470
if err != nil {
@@ -496,6 +497,19 @@ func readSearchPath(roleConfig pq.ByteaArray) []string {
496497
return nil
497498
}
498499

500+
// readLogStatement searches for a log_statement entry in the rolconfig array.
501+
// In case no such value is present, it returns empty.
502+
func readLogStatement(roleConfig pq.ByteaArray) string {
503+
for _, v := range roleConfig {
504+
config := string(v)
505+
if strings.HasPrefix(config, roleLogStatementAttr) {
506+
var result = strings.TrimPrefix(config, roleLogStatementAttr+"=")
507+
return result
508+
}
509+
}
510+
return ""
511+
}
512+
499513
// readStatementTimeout searches for a statement_timeout entry in the rolconfig array.
500514
// In case no such value is present, it returns nil.
501515
func readStatementTimeout(roleConfig pq.ByteaArray) (int, error) {

0 commit comments

Comments
 (0)