Re: [HACKERS] ereport bug
Hello all I see your patch, Tom. It works on my postgres 9.4 (intel x86_64). I write a letter if I can test it on others platform. Thank you! 14.01.2015, 21:40, "Tom Lane" : > Robert Haas writes: >> On Mon, Jan 12, 2015 at 6:27 AM, Dmitry Voronin >> wrote: >>> I am attaching to this letter a test case that shows the behavior >>> errcontext() macro and the way to fix it. >> So the upshot of this is that given errfinish(A, B, C), where A, B, >> and C are expressions, my gcc is choosing to evaluate C, then B, then >> A, then the errfinish call itself. But whoever wrote the errcontext() >> macro evidently thought, in this kind of situation, the compiler would >> be certain to evaluate A, then B, then C, then errfinish. But it >> doesn't. > > http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1f9bf05e539646103c518bcbb49c04919b238f7a > > regards, tom lane -- С уважением, Дмитрий Воронин -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] ereport bug
On Wed, Jan 14, 2015 at 1:40 PM, Tom Lane wrote: > Robert Haas writes: >> On Mon, Jan 12, 2015 at 6:27 AM, Dmitry Voronin >> wrote: >>> I am attaching to this letter a test case that shows the behavior >>> errcontext() macro and the way to fix it. > >> So the upshot of this is that given errfinish(A, B, C), where A, B, >> and C are expressions, my gcc is choosing to evaluate C, then B, then >> A, then the errfinish call itself. But whoever wrote the errcontext() >> macro evidently thought, in this kind of situation, the compiler would >> be certain to evaluate A, then B, then C, then errfinish. But it >> doesn't. > > http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1f9bf05e539646103c518bcbb49c04919b238f7a Oops, sorry. I missed that. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] ereport bug
Robert Haas writes: > On Mon, Jan 12, 2015 at 6:27 AM, Dmitry Voronin > wrote: >> I am attaching to this letter a test case that shows the behavior >> errcontext() macro and the way to fix it. > So the upshot of this is that given errfinish(A, B, C), where A, B, > and C are expressions, my gcc is choosing to evaluate C, then B, then > A, then the errfinish call itself. But whoever wrote the errcontext() > macro evidently thought, in this kind of situation, the compiler would > be certain to evaluate A, then B, then C, then errfinish. But it > doesn't. http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=1f9bf05e539646103c518bcbb49c04919b238f7a regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] ereport bug
On Mon, Jan 12, 2015 at 6:27 AM, Dmitry Voronin wrote: > I am attaching to this letter a test case that shows the behavior > errcontext() macro and the way to fix it. So the upshot of this is that given errfinish(A, B, C), where A, B, and C are expressions, my gcc is choosing to evaluate C, then B, then A, then the errfinish call itself. But whoever wrote the errcontext() macro evidently thought, in this kind of situation, the compiler would be certain to evaluate A, then B, then C, then errfinish. But it doesn't. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] ereport bug
Dmitry Voronin writes: > Hello, > postgresmen!I found incorrect execution of ereport() > macro. If we pass into ereport() function 2 or more arguments, the > macro errcontext does not correct execute. So, ereport() call stack > is:errstarterrcontext_msg />set_errcontext_domainerrmsgerrfinish />pg_unreachableThis bug > causes that error messages (for example, in PL/TCL) are > not localized.Solutions: />- Wrap all errcontext() macro in lang="en">brackets, that is errcontext("error message %s", "end > message") -> ( lang="en">errcontext("error message %s", "end > message")) lang="en">- Rewrite this macro- ???I am attaching to this letter a test case that shows the behavior errcontext() macro and the way to fix it.I am using postgresql 9.4 and test it on gcc 4.7 and gcc 4.8.1.-- Best regards, Dmitry Voronin (Please don't post HTML-only mail to the PG mailing lists ...) Hm ... the initial thought was that errcontext would never be used directly in an ereport() macro, but you're right that we now have some places that violate that rule. So the comma expression turns into a couple of arguments to errfinish, meaning the order of evaluation becomes compiler-dependent which is bad. I think the easiest fix is to have errstart initialize context_domain to the same value as domain. The order of evaluation is still compiler-dependent, but it no longer matters because any errcontext calls occurring textually within an ereport should be trying to select the same domain as the ereport anyway. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
[HACKERS] ereport bug
Hello, postgresmen! I found incorrect execution of ereport() macro. If we pass into ereport() function 2 or more arguments, the macro errcontext does not correct execute. So, ereport() call stack is: errstarterrcontext_msgset_errcontext_domainerrmsgerrfinishpg_unreachable This bug causes that error messages (for example, in PL/TCL) are not localized.Solutions:- Wrap all errcontext() macro in brackets, that is errcontext("error message %s", "end message") -> (errcontext("error message %s", "end message"))- Rewrite this macro- ??? I am attaching to this letter a test case that shows the behavior errcontext() macro and the way to fix it.I am using postgresql 9.4 and test it on gcc 4.7 and gcc 4.8.1.-- Best regards, Dmitry Voronin#include #define ereport_domain(elevel, domain, rest) \ do { \ const int elevel_ = (elevel); \ if (errstart(elevel_, __FILE__, __LINE__, PG_FUNCNAME_MACRO, domain)) \ errfinish rest; \ if (elevel_ >= 2) \ pg_unreachable(); \ } while(0) #define ereport(elevel, rest) \ ereport_domain(elevel, TEXTDOMAIN, rest) #define TEXTDOMAIN NULL #define PG_FUNCNAME_MACRO NULL #define ERROR 20 #define errcontext set_errcontext_domain(TEXTDOMAIN), errcontext_msg int set_errcontext_domain(const char *domain) { printf("set_errcontext_domain\n"); } int errstart(int elevel, const char *filename, int lineno, const char *funcname, const char *domain) { printf("errstart\n"); return 1; } void pg_unreachable() { printf("pg_unreachable\n"); } void errfinish(int dummy, ...) { printf("errfinish\n"); } int errcontext_msg(const char *fmt,...) { printf("errcontext_msg\n"); return 0; } int errmsg(const char *fmt, ...) { printf("errmsg\n"); return 0; } int main() { /* this is incorrect */ ereport(ERROR, (errmsg("%s", "error message"), errcontext("%s\nin PL/Tcl function \"%s\"", "test1", "test2"))); printf("\n"); /* this is correct */ ereport(ERROR, (errmsg("%s", "error message"), (errcontext("%s\nin PL/Tcl function \"%s\"", "test1", "test2"; return 0; } -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers