Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hy/plpython3 #2

Merged
merged 12 commits into from
Apr 21, 2022
Prev Previous commit
Next Next commit
fix: check hook
  • Loading branch information
yihong0618 committed Apr 14, 2022
commit 2654197a2a1785931822f25f0bad56d7faf214e1
25 changes: 18 additions & 7 deletions src/pl/plpython/plpy_main.c
Original file line number Diff line number Diff line change
@@ -69,6 +69,7 @@ static void PLy_pop_execution_context(void);
static int *plpython_version_bitmask_ptr = NULL;
static int plpython_version_bitmask = 0;
static const int plpython_python_version = PY_MAJOR_VERSION;
static bool inited = false;

/* initialize global variables */
PyObject *PLy_interp_globals = NULL;
@@ -85,15 +86,25 @@ bool PLy_enter_python_intepreter = false;
bool PLy_add_path = false;

/* GUC variables */
// need to add ifdef
#if PY_MAJOR_VERSION >= 3
char *plpython3_path = NULL;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make it static, it should not be used out of this file.

static char *plpython3_path = NULL;

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy that.

void
static void
assign_plpython3_python_path(const char *newval, void *extra)
{
if (Gp_role != GP_ROLE_EXECUTE)
if (inited)
ereport(WARNING, (errmsg("PYTHONPATH for plpython3 can only set once in one session")));
}
bool
check_path(char **newval, void **extra, GucSource source) {
if (PLy_add_path)
{
GUC_check_errmsg("SET PYTHONPATH for plpython3 can only set once in one session");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the above can be changed, then we need to modify this message.

return false;
}
PLy_add_path = true;
ereport(WARNING, (errmsg("PYTHONPATH for plpython3 can only set once in one session")));
return true;
}
#endif

void
@@ -157,10 +168,11 @@ _PG_init(void)
gettext_noop("Python path for plpython3."),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last comment :
'PYTHONPATH' for plpython3 will be clearer IMO.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy that.

NULL,
&plpython3_path,
NULL,
PGC_USERSET, 0,
"",
PGC_USERSET,
GUC_GPDB_NEED_SYNC,
check_path,
NULL,
assign_plpython3_python_path,
NULL);
#endif
pg_bindtextdomain(TEXTDOMAIN);
@@ -174,7 +186,6 @@ _PG_init(void)
static void
PLy_initialize(void)
{
static bool inited = false;

/*
* Check for multiple Python libraries before actively doing anything with