Skip to content

Commit cc8e8ae

Browse files
committed
Make identifier_alpha_transfor.c frontend-safe
identifier_alpha_transfor.c is compiled as part of frontend libpgport, but it previously hardwired backend-only header/allocation choices. Build error excerpt: ``` ../src/include/utils/elog.h:79:10: fatal error: 'utils/errcodes.h' file not found ``` Unify the FRONTEND split at the top of the file: choose postgres.h vs postgres_fe.h once, define ALLOC() once, and reuse ALLOC() in both conversion helpers. This keeps frontend/backend allocation behavior consistent and removes scattered per-callsite #ifdef blocks.
1 parent 0da228b commit cc8e8ae

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/port/identifier_alpha_transfor.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@
3434
*/
3535

3636

37+
#ifndef FRONTEND
3738
#include "postgres.h"
38-
39-
#include "c.h"
40-
#include "common/fe_memutils.h"
39+
#define ALLOC(size) palloc(size)
40+
#else
41+
#include "postgres_fe.h"
42+
#define ALLOC(size) pg_malloc(size)
43+
#endif
4144

4245
/*
4346
* transform upper to lower
@@ -51,7 +54,7 @@ down_character(const char *src, int len)
5154
Assert(src != NULL);
5255
Assert(len >= 0);
5356

54-
res = (char*)palloc(len + 1);
57+
res = ALLOC(len + 1);
5558
memcpy(res, src, len);
5659
res[len] = '\0';
5760
s = res;
@@ -77,7 +80,7 @@ upper_character(const char *src, int len)
7780
Assert(src != NULL);
7881
Assert(len >= 0);
7982

80-
res = (char*)palloc(len + 1);
83+
res = ALLOC(len + 1);
8184
memcpy(res, src, len);
8285
res[len] = '\0';
8386
s = res;

0 commit comments

Comments
 (0)