Skip to content

Commit 8d97a99

Browse files
committed
allow to use pg_temp schema in pragma table
1 parent dab99b7 commit 8d97a99

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/parser.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ plpgsql_check_pragma_table(PLpgSQL_checkstate *cstate, const char *str, int line
895895
{
896896
TokenizerState tstate;
897897
PragmaTokenType token, *_token;
898+
PragmaTokenType token2, *_token2;
898899
StringInfoData query;
899900
int32 typmod;
900901

@@ -905,11 +906,27 @@ plpgsql_check_pragma_table(PLpgSQL_checkstate *cstate, const char *str, int line
905906
&& _token->value != PRAGMA_TOKEN_QIDENTIF))
906907
elog(ERROR, "Syntax error (expected identifier)");
907908

908-
_token = get_token(&tstate, &token);
909-
if (!_token || _token->value != '(')
909+
_token2 = get_token(&tstate, &token2);
910+
911+
if (_token2 && _token2->value == '.')
912+
{
913+
char *nsname = make_ident(_token);
914+
915+
if (strcmp(nsname, "pg_temp") != 0)
916+
elog(ERROR, "only \"pg_temp\" schema is allowed");
917+
918+
_token = get_token(&tstate, &token);
919+
if (!_token || (_token->value != PRAGMA_TOKEN_IDENTIF
920+
&& _token->value != PRAGMA_TOKEN_QIDENTIF))
921+
elog(ERROR, "Syntax error (expected identifier)");
922+
923+
_token2 = get_token(&tstate, &token2);
924+
}
925+
926+
if (!_token2 || _token2->value != '(')
910927
elog(ERROR, "Syntax error (expected table specification)");
911928

912-
unget_token(&tstate, _token);
929+
unget_token(&tstate, _token2);
913930

914931
(void) get_type(&tstate, &typmod, false);
915932

0 commit comments

Comments
 (0)