Lexer issues

Поиск
Список
Период
Сортировка
Искать

Lexer issues

От:
Patrick REED <patrickreed352@gmail.com>
Дата:
Hi,

I am experimenting with postgres and am wondering if there is any tutorial on how to properly add a new command to postgres. 

I want to add a new constraint on "CREATE ROLE" that requires an integer, it has an identifier that is not a known (reserved or unreserved keyword) in postgres, say we call it TestPatrick. In other words, I want to do this "CREATE ROLE X TestPatrick=10". I am having an issue with having postgres recognize my new syntax.

I have seen this video: https://www.youtube.com/watch?v=uSEXTcEiXGQ and was able to add have my postgres compile with my added word (modified gram.y, kwlist.h, gram.cpp etc based on the video). However, when I use my syntax on a client session, it still doesn't recognize my syntax... Are there any specific lexer changes I need to make? I followed the example of CONNECTION LIMIT and tried to mimic it for Create ROLE. 

Best,
Patrick

Re: Lexer issues

От:
Julien Rouhaud <rjuju123@gmail.com>
Дата:
Hello,

On Mon, Apr 13, 2020 at 4:04 PM Patrick REED  wrote:
>
> I am experimenting with postgres and am wondering if there is any tutorial on how to properly add a new command to postgres.
>
> I want to add a new constraint on "CREATE ROLE" that requires an integer, it has an identifier that is not a known (reserved or unreserved keyword) in postgres, say we call it TestPatrick. In other words, I want to do this "CREATE ROLE X TestPatrick=10". I am having an issue with having postgres recognize my new syntax.
>
> I have seen this video: https://www.youtube.com/watch?v=uSEXTcEiXGQ and was able to add have my postgres compile with my added word (modified gram.y, kwlist.h, gram.cpp etc based on the video). However, when I use my syntax on a client session, it still doesn't recognize my syntax... Are there any specific lexer changes I need to make? I followed the example of CONNECTION LIMIT and tried to mimic it for Create ROLE.

I'd think that if you can get a successful compilation with a modified
gram.y (and any kwlist change needed) the new syntax should be
accepted (at least up to the parser, whether the utility command is
properly handled is another thing), since there's a single version of
the CreateRoleStmt.  Is there any chance that you're somehow
connecting to something else than the freshly make-install-ed binary,
or that the error is coming from later stage than parsing?


Re: Lexer issues

От:
Patrick REED <patrickreed352@gmail.com>
Дата:
Hi Julien,

Sorry for the late reply. I was able to solve the issue. It had to do with the extra syntax I had introduced in gram.y. However, since you mentioned the utility command, can you elaborate a bit more on that?

Thanks,
Patrick

On Tue, Apr 14, 2020 at 5:00 AM Julien Rouhaud <rjuju123@gmail.com> wrote:
Hello,

On Mon, Apr 13, 2020 at 4:04 PM Patrick REED <patrickreed352@gmail.com> wrote:
>
> I am experimenting with postgres and am wondering if there is any tutorial on how to properly add a new command to postgres.
>
> I want to add a new constraint on "CREATE ROLE" that requires an integer, it has an identifier that is not a known (reserved or unreserved keyword) in postgres, say we call it TestPatrick. In other words, I want to do this "CREATE ROLE X TestPatrick=10". I am having an issue with having postgres recognize my new syntax.
>
> I have seen this video: https://www.youtube.com/watch?v=uSEXTcEiXGQ and was able to add have my postgres compile with my added word (modified gram.y, kwlist.h, gram.cpp etc based on the video). However, when I use my syntax on a client session, it still doesn't recognize my syntax... Are there any specific lexer changes I need to make? I followed the example of CONNECTION LIMIT and tried to mimic it for Create ROLE.

I'd think that if you can get a successful compilation with a modified
gram.y (and any kwlist change needed) the new syntax should be
accepted (at least up to the parser, whether the utility command is
properly handled is another thing), since there's a single version of
the CreateRoleStmt.  Is there any chance that you're somehow
connecting to something else than the freshly make-install-ed binary,
or that the error is coming from later stage than parsing?

Re: Lexer issues

От:
Julien Rouhaud <rjuju123@gmail.com>
Дата:
On Fri, Apr 17, 2020 at 3:57 AM Patrick REED  wrote:
>
> Hi Julien,
>
> Sorry for the late reply. I was able to solve the issue. It had to do with the extra syntax I had introduced in gram.y. However, since you mentioned the utility command, can you elaborate a bit more on that?

Utility commands are basically everything except DML, with each
command having its own set of function(s) to actually implement it.
So if you modify the parser you want to make sure that those functions
are also modified to accept the changes. The main entry point is
ProcessUtility() in utility.c.  Or maybe you wanted more specific
information?


FAQ