Sync ECPG scanner with core

From: John Naylor <jcnaylor(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Sync ECPG scanner with core
Date: 2018-09-30 09:32:53
Message-ID: CAJVSVGWGqY9YBs2EwtRUkbNv=hXkN8yRPOoD1wxE6COgvvrz5g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

Commit 21c8ee7946 was one of several that sync'd the backend scanner
with the psql scanner, with the commit message stating "Someday it'd
be nice to make ecpg's pgc.l more easily diff'able too, but today is
not that day." Attached is a set of patches to make progress towards
that. The ECPG tests pass. There's probably more that could be done,
but this seems like a good base to start from.

0001:
-Bring comments in line, and adjust formatting and whitespace.
-Move the block of whitespace patterns.
-Include missing exclusive states in the comment about them. I haven't
filled in the missing comments, leaving that to someone more
knowledgeable than me. It might be good to get rid of the block
comment in favor of one comment line per state, but this patch doesn't
go that far (it would need to be done for the three main scanners).
-While at it, move the rule for C++-style comments to the section with
the other ECPG-specific rules.
-Note: If you use "diff -w", it'll be much easier to read.

0002:
-Just a couple rearrangements to make 0003 easier to read

0003:
-Use a Flex feature called "start condition scope" to make some of the
ECPG rules more similar to the core scanner rules.

Finally, although unrelated to the subject at hand,
0004:
-scanner_init() is not currently used, in favor of lex_init(), and
neither is scanner_finish(), so get rid of them. Maybe it'd be cleaner
to actually use scanner_finish(), but preproc runs are short-lived
anyway.
-base_yyerror() is used once, but every other call site uses
mmerror(), so use that instead.
-mm_realloc() is declared but not defined, so remove the declaration.

I've attached a diff between the core and ECPG scanner with the above
patches applied.

In the course of doing this, I noticed a few other possible ECPG
scanner cleanups to consider, although the payoff might not justify
the work involved:

-Copy process_integer_literal() from the core scanner (maybe only if
decimal_fail is also brought over).
-Match core's handling of unicode escapes, even though pgc.l is not backup-free.
-Use reentrant APIs?
-Does ECPG still need its own functions for mm_alloc() and
mm_strdup(), if we have equivalents in src/common?

Thanks,
John Naylor

Attachment Content-Type Size
v1-core2ecpg.diff text/plain 64.6 KB
v1-0001-First-pass-at-syncing-ECPG-scanner-with-the-core-.patch text/x-patch 29.2 KB
v1-0002-Prepatory-refactoring-for-next-commit.patch text/x-patch 2.6 KB
v1-0003-Use-start-condition-scopes-in-the-core-psql-and-E.patch text/x-patch 8.5 KB
v1-0004-Remove-unused-functions-and-declarations-from-ECP.patch text/x-patch 3.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-09-30 12:40:31 Re: Use durable_unlink for .ready and .done files for WAL segment removal
Previous Message Matteo Beccati 2018-09-30 08:49:21 Re: [HACKERS] kqueue