Re: Bugs in ecpg's macro mechanism

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: Bugs in ecpg's macro mechanism
Дата
Msg-id 20240415231044.fjjibtnwcypowzni@awork3.anarazel.de
обсуждение исходный текст
Ответ на Bugs in ecpg's macro mechanism  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Bugs in ecpg's macro mechanism  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

On 2024-04-15 17:48:32 -0400, Tom Lane wrote:
> I started looking into the ideas discussed at [1] about reimplementing
> ecpg's string handling.  Before I could make any progress I needed
> to understand the existing input code, part of which is the macro
> expansion mechanism ... and the more I looked at that the more bugs
> I found, not to mention that it uses misleading field names and is
> next door to uncommented.

As part of the discussion leading to [1] I had looked at parse.pl and found it
fairly impressively obfuscated and devoid of helpful comments.


> I found two ways to crash ecpg outright and several more cases in which it'd
> produce surprising behavior.

:/


> One thing it's missing is any test of the behavior when command-line macro
> definitions are carried from one file to the next one.  To test that, we'd
> need to compile more than one ecpg input file at a time.  I can see how to
> kluge the Makefiles to make that happen, basically this'd do:
> 
>  define.c: define.pgc $(ECPG_TEST_DEPENDENCIES)
> -    $(ECPG) -DCMDLINESYM=123 -o $@ $<
> +    $(ECPG) -DCMDLINESYM=123 -o $@ $< $<
> 
> But I have no idea about making it work in meson.  Any suggestions?

So you just want to compile define.c twice? The below should suffice:

diff --git i/src/interfaces/ecpg/test/sql/meson.build w/src/interfaces/ecpg/test/sql/meson.build
index e04684065b0..202dc69c6ea 100644
--- i/src/interfaces/ecpg/test/sql/meson.build
+++ w/src/interfaces/ecpg/test/sql/meson.build
@@ -31,7 +31,7 @@ pgc_files = [
 ]
 
 pgc_extra_flags = {
-  'define': ['-DCMDLINESYM=123'],
+  'define': ['-DCMDLINESYM=123', files('define.pgc')],
   'oldexec': ['-r', 'questionmarks'],
 }
 

I assume that was just an test hack, because it leads to the build failing
because of main being duplicated. But it'd work the same with another, "non
overlapping", file.

Greetings,

Andres Freund



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: Cutting support for OpenSSL 1.0.1 and 1.0.2 in 17~?
Следующее
От: Tom Lane
Дата:
Сообщение: Time to back-patch libxml deprecation fixes?