How to implement input by PostgreSQL
This article will explain in detail how to achieve input in PostgreSQL. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
I. input
The response of standard PG to zz_sysdate is:
Testdb=# select zz_sysdate from T1 error: column "zz_sysdate" does not existLINE 1: select zz_sysdate from T1
An error is reported and the prompt column does not exist.
In order for PG to recognize zz_sysdate, the lexical and parsing modules need to be modified.
Lexical morphology
The files involved include scan.l,kwlist.h
Scan.l:
Lexical file, zz_sysdate will be recognized as IDENT, this file does not need to be modified
Kwlist.h:
Keyword list, add a sentence at the end:
PG_KEYWORD ("zz_sysdate", ZZ_SYSDATE, RESERVED_KEYWORD)
RESERVED_KEYWORD means reserved keyword
Grammar
Syntax file is gram.y. You need to add ZZ_SYSDATE.
/ / add token, which corresponds to% token of ZZ_SYSDATE in lexical analysis. ZZ_SYSDATE// production reserved_keyword add ZZ_SYSDATE// Note: reserved_keyword is a non-Terminator, ZZ_SYSDATE is a Terminator reserved_keyword:... | ZZ_SYSDATE / / refer to current_date and add... in func_expr_common_subexpr. | ZZ_SYSDATE {$$= makeSQLValueFunction (SVFOP_ZZ_SYSDATE,-1, @ 1);}
In addition, to identify SVFOP_ZZ_SYSDATE, add to the yytokentype enumeration variable of preproc.h
ZZ_SYSDATE = 793
After the above modifications, PG can now recognize zz_sysdate, but the implementation will make errors.
This is the end of the article on "how to input PostgreSQL". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.