In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "what is the role of Declarations in PostgreSQL". In daily operation, I believe that many people have doubts about the role of Declarations in PostgreSQL. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "what is the role of Declarations in PostgreSQL?" Next, please follow the editor to study!
The Flex input file consists of four parts:
% {Declarations%} Definitions%%Rules%%User subroutinesDeclarations
The part contained by% {and%} is the Declarations part, which is all C code and will be copy into the lex.yy.c file intact.
More important definitions include:
YYSTYPE-Bison uses a union consortium to store values of all possible types, and the global variable yyvalue is of type YYSTYPE.
% top {/ *-* scan.l * lexical scanner for PostgreSQL * PostgreSQL lexical scanner * * NOTE NOTE NOTE: * Special Note: * The rules in this file must be kept in sync with src/fe_utils/psqlscan.l! * the rules in this file must be consistent with those in the src/fe_utils/psqlscan.l file!! * * The rules are designed so that the scanner never has to backtrack * in the sense that there is always a rule that can match the input * consumed so far (the rule action may internally throw back some input * with yyless (), however). As explained in the flex manual, this makes * for a useful speed increase-about a third faster than a plain-CF * lexer, in simple testing. The extra complexity is mostly in the rules * for handling float numbers and continued string literals. If you change * the lexical rules, verify that you haven't broken the no-backtrack * property by running flex with the "- b" option and checking that the * resulting "lex.backup" file says that no backing up is needed. (As of * Postgres 9.2, this check is made automatically by the Makefile.) * the rule is designed so that the scanner does not need to backtrack, ensuring that there must be a rule matching the input * (however, the rule action may use yyless () throw back some input internally). * as stated in the Flex manual, this can improve performance-* in the case of simple testing, there is about a performance improvement of 1 CF 3 over the ordinary-CF lexical analyzer. * the additional complexity is mainly reflected in the rules for dealing with floating-point numbers and consecutive string text. * if the lexical rules are modified, ensure that the no-backtracking convention is not broken by executing Flex with the-b option, * and stick to the result file "lex.backup" to confirm that no backup is needed. * (on PG 9.2, this check is performed automatically via Makefile) * * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994 Regents of the University of California * * IDENTIFICATION * src/backend/parser/scan.l * *-- * / # include "postgres.h" # include # include # include "common/string.h "# include" parser/gramparse.h "# include" parser/parser.h "/ * only needed for GUC variables * / # include" parser/scansup.h "# include" mb/pg_wchar.h} / /-declare part% {/ * LCOV_EXCL_START * / / * Avoid exit () on fatal scanner errors (a bit ugly-- see yy_fatal_error) * / / when a fatal error occurs in the scanner Avoid calling exit () to exit # undef fprintf#define fprintf (file, fmt, msg) fprintf_to_ereport (fmt, msg) static voidfprintf_to_ereport (const char * fmt, const char * msg) {ereport (ERROR, (errmsg_internal ("% s", msg) } / * GUC variables. This is a DIRECT violation of the warning given at the * head of gram.y, ie flex/bison code must not depend on any GUC variables; * as such, changing their values can induce very unintuitive behavior. * But we shall have to live with it until we can remove these variables. * GUC parameter variable. This directly violates the conventions proposed in gram.y, such as flex/bison code cannot rely on GUC variables; * therefore, changing their values will lead to unknown consequences. * but before removing these variables, I have to "live" * / int backslash_quote = BACKSLASH_QUOTE_SAFE_ENCODING;bool escape_string_warning = true;bool standard_conforming_strings = true;/* * Set the type of YYSTYPE. * set YYSTYPE. * in Bison, the type of global variable yylval is YYSTYPE, and the default is int * Internally, bison declares each value as a C union that includes all of the types. * You list all of the types in% union declarations. * Bison turns them into a typedef for a union type called YYSTYPE. * / # define YYSTYPE core_YYSTYPE/* * Set the type of yyextra. All state variables used by the scanner should * be in yyextra, * not* statically allocated. * set the data type of yyextra. The state variables used by all scanners should be in yyextra, not statically assigned. * / # define YY_EXTRA_TYPE core_yy_extra_type * / * * Each call to yylex must set yylloc to the location of the found token * (expressed as a byte offset from the start of the input text). * When we parse a token that requires multiple lexer rules to process, * this should be done in the first such rule, else yylloc will point * into the middle of the token. * every time you call yylex, you must set yylloc to point to the location of the discovered token. * (byte offset calculated from the input text) * when analyzing a token that requires multiple word rules to be processed, * this action should be done the first time the rule is applied, otherwise the yylloc will point to the middle of the token. * / # define SET_YYLLOC () (* (yylloc) = yytext-yyextra- > scanbuf) / * * Advance yylloc by the given number of bytes. * reposition yylloc by the given number of bytes * / # define ADVANCE_YYLLOC (delta) (* (yylloc) + = (delta)) # define startlit () (yyextra- > literallen = 0) static void addlit (char * ytext, int yleng, core_yyscan_t yyscanner); static void addlitchar (unsigned char ychar, core_yyscan_t yyscanner); static char * litbufdup (core_yyscan_t yyscanner); static char * litbuf_udeescape (unsigned char escape, core_yyscan_t yyscanner) Static unsigned char unescape_single_char (unsigned char c, core_yyscan_t yyscanner); static int process_integer_literal (const char * token, YYSTYPE * lval); static bool is_utf16_surrogate_first (pg_wchar c); static bool is_utf16_surrogate_second (pg_wchar c); static pg_wchar surrogate_pair_to_codepoint (pg_wchar first, pg_wchar second); static void addunicode (pg_wchar c, yyscan_t yyscanner); static bool check_uescapechar (unsigned char escape) # define yyerror (msg) scanner_yyerror (msg, yyscanner) # define lexer_errposition () scanner_errposition (* (yylloc), yyscanner) static void check_string_escape_warning (unsigned char ychar, core_yyscan_t yyscanner); static void check_escape_warning (core_yyscan_t yyscanner); / * Work around a bug in flex 2.5.35: it emits a couple of functions that * it forgets to emit declarations for. Since we use-Wmissing-prototypes, * this would cause warnings. Providing our own declarations should be * harmless even when the bug gets fixed. * Flex 2.5.35 there is a bug that ignores the function but does not ignore the function declaration. * this causes a warning to appear because the-Wmissing-prototypes option is used. * even if bug fixes, there may be problems with the declaration of providing PG. * / extern int core_yyget_column (yyscan_t yyscanner); extern void core_yyset_column (int column_no, yyscan_t yyscanner);%} at this point, the study of "what is the role of Declarations in PostgreSQL" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.