diff options
Diffstat (limited to 'src/test/regress/regress.c')
-rw-r--r-- | src/test/regress/regress.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index ba3532a51e8..6764589418e 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -639,6 +639,29 @@ make_tuple_indirect(PG_FUNCTION_ARGS) PG_RETURN_POINTER(newtup->t_data); } +PG_FUNCTION_INFO_V1(get_environ); + +Datum +get_environ(PG_FUNCTION_ARGS) +{ + extern char **environ; + int nvals = 0; + ArrayType *result; + Datum *env; + + for (char **s = environ; *s; s++) + nvals++; + + env = palloc(nvals * sizeof(Datum)); + + for (int i = 0; i < nvals; i++) + env[i] = CStringGetTextDatum(environ[i]); + + result = construct_array(env, nvals, TEXTOID, -1, false, TYPALIGN_INT); + + PG_RETURN_POINTER(result); +} + PG_FUNCTION_INFO_V1(regress_setenv); Datum |