postgresql/src/interfaces/ecpg/preproc
Tom Lane 0778eb79b1 Improve perl style in ecpg's parser-construction scripts.
parse.pl and check_rules.pl used "no warnings 'uninitialized'",
which doesn't seem like it measures up to current project standards.
Removing that shows that it was hiding various places that accessed
off the end of an array, which are easily protected by minor logic
adjustments.  There's no change in the script results.

While here, improve the Makefile rule that invokes these scripts.
It neglected to depend on check_rules.pl, so that editing that file
didn't result in re-running the check; and it ran check_rules.pl
after building preproc.y, so that if check_rules.pl did fail the
next "make" attempt would just bypass it.  check_rules.pl failures
are sufficiently un-heard-of that I don't feel a need to back-patch
this.

Discussion: https://postgr.es/m/838180.1658181982@sss.pgh.pa.us
2022-07-18 19:43:16 -04:00
..
po NLS: Put list of available languages into LINGUAS files 2022-07-13 08:19:17 +02:00
.gitignore Replace the data structure used for keyword lookup. 2019-01-06 17:02:57 -05:00
c_keywords.c Make the order of the header file includes consistent in non-backend modules. 2019-10-25 07:41:52 +05:30
c_kwlist.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
check_rules.pl Improve perl style in ecpg's parser-construction scripts. 2022-07-18 19:43:16 -04:00
descriptor.c Remove redundant null pointer checks before free() 2022-07-03 11:47:15 +02:00
ecpg.addons Fix connection handling for DEALLOCATE and DESCRIBE statements 2021-08-13 10:45:08 +02:00
ecpg.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
ecpg.header Fix incorrect merge in ECPG code with DECLARE 2021-08-25 15:16:31 +09:00
ecpg.tokens Reduce size of backend scanner's tables. 2020-01-13 15:04:31 -05:00
ecpg.trailer Fix ECPG's handling of type names that match SQL keywords. 2022-07-12 17:05:46 -04:00
ecpg.type Fix ECPG's handling of type names that match SQL keywords. 2022-07-12 17:05:46 -04:00
ecpg_keywords.c Make the order of the header file includes consistent in non-backend modules. 2019-10-25 07:41:52 +05:30
ecpg_kwlist.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
keywords.c Update copyright for 2022 2022-01-07 19:04:57 -05:00
Makefile Improve perl style in ecpg's parser-construction scripts. 2022-07-18 19:43:16 -04:00
nls.mk Revert "Use wildcards instead of manually-maintained file lists in */nls.mk." 2022-07-13 14:29:10 -04:00
output.c Fix connection handling for DEALLOCATE and DESCRIBE statements 2021-08-13 10:45:08 +02:00
parse.pl Improve perl style in ecpg's parser-construction scripts. 2022-07-18 19:43:16 -04:00
parser.c SQL/JSON constructors 2022-03-27 17:03:34 -04:00
pgc.l Fix ECPG's handling of type names that match SQL keywords. 2022-07-12 17:05:46 -04:00
preproc_extern.h Fix ECPG's handling of type names that match SQL keywords. 2022-07-12 17:05:46 -04:00
README.parser Move parse2.pl to parse.pl 2011-06-14 07:34:00 +03:00
type.c Refer to bug report address by symbol rather than hardcoding 2020-02-28 13:12:21 +01:00
type.h Fix connection handling for DEALLOCATE and DESCRIBE statements 2021-08-13 10:45:08 +02:00
variable.c Fix ECPG's handling of type names that match SQL keywords. 2022-07-12 17:05:46 -04:00

ECPG modifies and extends the core grammar in a way that
1) every token in ECPG is <str> type. New tokens are
   defined in ecpg.tokens, types are defined in ecpg.type
2) most tokens from the core grammar are simply converted
   to literals concatenated together to form the SQL string
   passed to the server, this is done by parse.pl.
3) some rules need side-effects, actions are either added
   or completely overridden (compared to the basic token
   concatenation) for them, these are defined in ecpg.addons,
   the rules for ecpg.addons are explained below.
4) new grammar rules are needed for ECPG metacommands.
   These are in ecpg.trailer.
5) ecpg.header contains common functions, etc. used by
   actions for grammar rules.

In "ecpg.addons", every modified rule follows this pattern:
       ECPG: dumpedtokens postfix
where "dumpedtokens" is simply tokens from core gram.y's
rules concatenated together. e.g. if gram.y has this:
       ruleA: tokenA tokenB tokenC {...}
then "dumpedtokens" is "ruleAtokenAtokenBtokenC".
"postfix" above can be:
a) "block" - the automatic rule created by parse.pl is completely
    overridden, the code block has to be written completely as
    it were in a plain bison grammar
b) "rule" - the automatic rule is extended on, so new syntaxes
    are accepted for "ruleA". E.g.:
      ECPG: ruleAtokenAtokenBtokenC rule
          | tokenD tokenE { action_code; }
          ...
    It will be substituted with:
      ruleA: <original syntax forms and actions up to and including
                    "tokenA tokenB tokenC">
             | tokenD tokenE { action_code; }
             ...
c) "addon" - the automatic action for the rule (SQL syntax constructed
    from the tokens concatenated together) is prepended with a new
    action code part. This code part is written as is's already inside
    the { ... }

Multiple "addon" or "block" lines may appear together with the
new code block if the code block is common for those rules.