Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of User subroutines in PostgreSQL

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "what is the role of User subroutines in PostgreSQL". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The Flex input file consists of four parts:

% {Declarations%} Definitions%%Rules%%User subroutinesUser subroutines

After the rule comes the custom routine. The routines defined in scan.l are mainly to parse the input SQL statements and perform initialization and clean-up work.

/ * LCOV_EXCL_STOP * / * * Arrange access to yyextra for subroutines of the main yylex () function. * We expect each subroutine to have a yyscanner parameter. Rather than * use the yyget_xxx functions, which might or might not get inlined by the * compiler, we cheat just a bit and cast yyscanner to the right type. * provide yyextra access to the main yylex () function. * We expect every subroutine to have a parameter: yyscanner. * instead of using the yyget_xxx function (which may or may not be inlined by the compiler), we force yyscanner to be the correct type. * / # undef yyextra#define yyextra ((struct yyguts_t *) yyscanner)-> yyextra_r) / * Likewise for a couple of other things we need. * / / define other things you need: yylloc/yyleng#undef yylloc#define yylloc ((struct yyguts_t *) yyscanner)-> yylloc_r) # undef yyleng#define yyleng (struct yyguts_t *) yyscanner)-> yyleng_r) / * * scanner_errposition * Report a lexer or grammar error cursor position, if possible. * scanner_errposition: if possible, report the lexical or grammatical error location * * This is expected to be used within an ereport () call. The return value * is a dummy (always 0, in fact). * this routine is used in the ereport () call. The return value is a pseudo column (usually 0 in fact). * * Note that this can only be used for messages emitted during raw parsing * (essentially, scan.l and gram.y), since it requires the yyscanner struct * to still be available. Note that this can only be used for messages generated during the original parsing (scan.l & gram.y), * because it requires that the yyscanner structure is still available. * / intscanner_errposition (int location, core_yyscan_t yyscanner) {int pos; if (location)

< 0) return 0; /* no-op if location is unknown */ /* Convert byte offset to character number */ pos = pg_mbstrlen_with_len(yyextra->

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report