Index: pgaudit/pgaudit.c
===================================================================
--- pgaudit.orig/pgaudit.c
+++ pgaudit/pgaudit.c
@@ -35,7 +35,13 @@
 #include "utils/rel.h"
 #include "utils/syscache.h"
 #include "utils/timestamp.h"
+#if PG_VERSION_NUM >= 100000
 #include "utils/varlena.h"
+#endif
+
+#if (PG_VERSION_NUM >= 90500 && PG_VERSION_NUM < 90600)
+#define LOG_SERVER_ONLY COMMERROR
+#endif
 
 #if (PG_VERSION_NUM >= 90500 && PG_VERSION_NUM < 90600)
 #define LOG_SERVER_ONLY COMMERROR
@@ -601,7 +607,9 @@ log_audit_event(AuditEventStackItem *sta
             {
                 /* READ statements */
                 case T_CopyStmt:
+#if PG_VERSION_NUM >= 100000
                 case T_DeclareCursorStmt:
+#endif
                 case T_SelectStmt:
                 case T_PrepareStmt:
                 case T_PlannedStmt:
@@ -1345,6 +1353,7 @@ pgaudit_ExecutorCheckPerms_hook(List *ra
 /*
  * Hook ProcessUtility to do session auditing for DDL and utility commands.
  */
+#if PG_VERSION_NUM >= 100000
 static void
 pgaudit_ProcessUtility_hook(PlannedStmt *pstmt,
                             const char *queryString,
@@ -1353,6 +1362,15 @@ pgaudit_ProcessUtility_hook(PlannedStmt
                             QueryEnvironment *queryEnv,
                             DestReceiver *dest,
                             char *completionTag)
+#else
+static void
+pgaudit_ProcessUtility_hook(Node *parsetree,
+                             const char *queryString,
+                             ProcessUtilityContext context,
+                             ParamListInfo params,
+                             DestReceiver *dest,
+                             char *completionTag)
+#endif
 {
     AuditEventStackItem *stackItem = NULL;
     int64 stackId = 0;
@@ -1376,9 +1394,15 @@ pgaudit_ProcessUtility_hook(PlannedStmt
             stackItem = stack_push();
 
         stackId = stackItem->stackId;
+#if PG_VERSION_NUM >= 100000
         stackItem->auditEvent.logStmtLevel = GetCommandLogLevel(pstmt->utilityStmt);
         stackItem->auditEvent.commandTag = nodeTag(pstmt->utilityStmt);
         stackItem->auditEvent.command = CreateCommandTag(pstmt->utilityStmt);
+#else
+        stackItem->auditEvent.logStmtLevel = GetCommandLogLevel(parsetree);
+        stackItem->auditEvent.commandTag = nodeTag(parsetree);
+        stackItem->auditEvent.command = CreateCommandTag(parsetree);
+#endif
         stackItem->auditEvent.commandText = queryString;
 
         /*
@@ -1392,12 +1416,21 @@ pgaudit_ProcessUtility_hook(PlannedStmt
     }
 
     /* Call the standard process utility chain. */
+#if PG_VERSION_NUM >= 100000
     if (next_ProcessUtility_hook)
         (*next_ProcessUtility_hook) (pstmt, queryString, context, params,
                                      queryEnv, dest, completionTag);
     else
         standard_ProcessUtility(pstmt, queryString, context, params,
                                 queryEnv, dest, completionTag);
+#else
+    if (next_ProcessUtility_hook)
+        (*next_ProcessUtility_hook) (parsetree, queryString, context,
+                                     params, dest, completionTag);
+    else
+        standard_ProcessUtility(parsetree, queryString, context,
+                                params, dest, completionTag);
+#endif
 
     /*
      * Process the audit event if there is one.  Also check that this event
