Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 35a1e1d

Browse files
committed
Fix portability issue in pg_audit.
"%ld" is not a portable way to print int64's. This may explain the buildfarm crashes we're seeing --- it seems to make dromedary happy, at least.
1 parent 6c9e93d commit 35a1e1d

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

contrib/pg_audit/pg_audit.c

+20-15
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ stack_pop(int64 stackId)
384384
if (auditEventStack != NULL && auditEventStack->stackId == stackId)
385385
MemoryContextDelete(auditEventStack->contextAudit);
386386
else
387-
elog(ERROR, "pg_audit stack item %ld not found on top - cannot pop",
388-
stackId);
387+
elog(ERROR, "pg_audit stack item " INT64_FORMAT " not found on top - cannot pop",
388+
stackId);
389389
}
390390

391391
/*
@@ -403,10 +403,9 @@ stack_valid(int64 stackId)
403403

404404
/* If we didn't find it, something went wrong. */
405405
if (nextItem == NULL)
406-
elog(ERROR, "pg_audit stack item %ld not found - top of stack is %ld",
407-
stackId, auditEventStack == NULL ? -1 : auditEventStack->stackId);
408-
409-
return;
406+
elog(ERROR, "pg_audit stack item " INT64_FORMAT " not found - top of stack is " INT64_FORMAT "",
407+
stackId,
408+
auditEventStack == NULL ? (int64) -1 : auditEventStack->stackId);
410409
}
411410

412411
/*
@@ -672,15 +671,21 @@ log_audit_event(AuditEventStackItem *stackItem)
672671
appendStringInfoString(&auditStr,
673672
"<previously logged>,<previously logged>");
674673

675-
/* Log the audit entry */
676-
elog(auditLogLevel, "AUDIT: %s,%ld,%ld,%s,%s",
677-
stackItem->auditEvent.granted ?
678-
AUDIT_TYPE_OBJECT : AUDIT_TYPE_SESSION,
679-
stackItem->auditEvent.statementId,
680-
stackItem->auditEvent.substatementId,
681-
className, auditStr.data);
682-
683-
stackItem->auditEvent.logged = true;
674+
/*
675+
* Log the audit entry. Note: use of INT64_FORMAT here is bad for
676+
* translatability, but we currently haven't got translation support in
677+
* pg_audit anyway.
678+
*/
679+
ereport(auditLogLevel,
680+
(errmsg("AUDIT: %s," INT64_FORMAT "," INT64_FORMAT ",%s,%s",
681+
stackItem->auditEvent.granted ?
682+
AUDIT_TYPE_OBJECT : AUDIT_TYPE_SESSION,
683+
stackItem->auditEvent.statementId,
684+
stackItem->auditEvent.substatementId,
685+
className,
686+
auditStr.data)));
687+
688+
stackItem->auditEvent.logged = true;
684689

685690
MemoryContextSwitchTo(contextOld);
686691
}

0 commit comments

Comments
 (0)