diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index d6254d820f..1bd151c941 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -601,22 +601,6 @@ open_auth_file(const char *filename, int elevel, int depth, return NULL; } - /* - * When opening the top-level file, create the memory context used for the - * tokenization. This will be closed with this file when coming back to - * this level of cleanup. - */ - if (depth == 0) - { - /* - * A context may be present, but assume that it has been eliminated - * already. - */ - tokenize_context = AllocSetContextCreate(CurrentMemoryContext, - "tokenize_context", - ALLOCSET_START_SMALL_SIZES); - } - file = AllocateFile(filename, "r"); if (file == NULL) { @@ -634,6 +618,22 @@ open_auth_file(const char *filename, int elevel, int depth, return NULL; } + /* + * When opening the top-level file, create the memory context used for the + * tokenization. This will be closed with this file when coming back to + * this level of cleanup. + */ + if (depth == 0) + { + /* + * A context may be present, but assume that it has been eliminated + * already. + */ + tokenize_context = AllocSetContextCreate(CurrentMemoryContext, + "tokenize_context", + ALLOCSET_START_SMALL_SIZES); + } + return file; }