postgresql/src/interfaces/ecpg/preproc
Tom Lane 4b538727e2 Fix make rules that generate multiple output files.
For years, our makefiles have correctly observed that "there is no correct
way to write a rule that generates two files".  However, what we did is to
provide empty rules that "generate" the secondary output files from the
primary one, and that's not right either.  Depending on the details of
the creating process, the primary file might end up timestamped later than
one or more secondary files, causing subsequent make runs to consider the
secondary file(s) out of date.  That's harmless in a plain build, since
make will just re-execute the empty rule and nothing happens.  But it's
fatal in a VPATH build, since make will expect the secondary file to be
rebuilt in the build directory.  This would manifest as "file not found"
failures during VPATH builds from tarballs, if we were ever unlucky enough
to ship a tarball with apparently out-of-date secondary files.  (It's not
clear whether that has ever actually happened, but it definitely could.)

To ensure that secondary output files have timestamps >= their primary's,
change our makefile convention to be that we provide a "touch $@" action
not an empty rule.  Also, make sure that this rule actually gets invoked
during a distprep run, else the hazard remains.

It's been like this a long time, so back-patch to all supported branches.

In HEAD, I skipped the changes in src/backend/catalog/Makefile, because
those rules are due to get replaced soon in the bootstrap data format
patch, and there seems no need to create a merge issue for that patch.
If for some reason we fail to land that patch in v11, we'll need to
back-fill the changes in that one makefile from v10.

Discussion: https://postgr.es/m/18556.1521668179@sss.pgh.pa.us
2018-03-23 13:46:00 -04:00
..
po Translation updates 2017-08-07 13:55:34 -04:00
.gitignore Move keywords.c/kwlookup.c into src/common/. 2016-03-23 20:22:08 -04:00
c_keywords.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
check_rules.pl Update copyright for 2018 2018-01-02 23:30:12 -05:00
descriptor.c Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
ecpg.addons Use "%option prefix" to set API names in ecpg's lexer. 2016-12-11 14:54:25 -05:00
ecpg.c Add Oracle like handling of char arrays. 2018-03-14 00:54:13 +01:00
ecpg.header Fixed ECPG to correctly handle out-of-scope cursor declarations with pointers 2017-09-12 04:53:36 +02:00
ecpg.tokens SQL procedures 2017-11-30 11:03:20 -05:00
ecpg.trailer SQL procedures 2017-11-30 11:03:20 -05:00
ecpg.type Changed ecpg parser to allow RETURNING clauses without attached C variables. 2017-08-14 11:29:34 +02:00
ecpg_keywords.c SQL procedures 2017-11-30 11:03:20 -05:00
extern.h Add Oracle like handling of char arrays. 2018-03-14 00:54:13 +01:00
keywords.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
Makefile Fix make rules that generate multiple output files. 2018-03-23 13:46:00 -04:00
nls.mk ecpg: Split off mmfatal() from mmerror() 2013-11-19 21:56:54 -05:00
output.c Set connection back to NULL after freeing it. 2018-03-13 16:22:28 +01:00
parse.pl Update copyright for 2018 2018-01-02 23:30:12 -05:00
parser.c Update copyright for 2018 2018-01-02 23:30:12 -05:00
pgc.l Move strtoint() to common 2018-03-13 10:21:09 -04:00
README.parser Move parse2.pl to parse.pl 2011-06-14 07:34:00 +03:00
type.c Cope with indicator arrays that do not have the correct length. 2018-01-13 14:57:49 +01:00
type.h Add some const decorations to prototypes 2017-11-10 13:38:57 -05:00
variable.c Remove unnecessary parentheses in return statements 2017-09-05 14:52:55 -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.