Re: [BUGS] incompatible pointer type

2011-10-19 Thread Robert Young
As I tested, if you explicit appoint a union tag, the OpenBSD m4 and
GNU m4 work identically.
And This explicit definition just corresponding to the forward-declaration.

As mentioned in
http://www.gnu.org/s/bison/manual/html_node/Union-Decl.html
This feature is a POSIX  extension.
I don't know what impact to other platform.

So I suppose this should be the appropriate patch to solve this problem

diff --git a/src/pl/plpgsql/src/gram.y b/src/pl/plpgsql/src/gram.y
index 4e2b705..81a91e4 100644
--- a/src/pl/plpgsql/src/gram.y
+++ b/src/pl/plpgsql/src/gram.y
@@ -112,7 +112,7 @@ static  List
*read_raise_options(void);
 %name-prefix=plpgsql_yy
 %locations

-%union {
+%union YYSTYPE {
core_YYSTYPEcore_yystype;
/* these fields must match core_YYSTYPE: */
int ival;

On 2011-10-19, Robert Young yay...@gmail.com wrote:
 Perfect!
 I've update my m4 to version 1.4.13
 from:
 http://ftp.openbsd.org/pub/OpenBSD/4.9/packages/amd64/m4-1.4.13.tgz
 the problem solved perfectly!
 Thank You !!!

 # /usr/bin/gm4 --version
 m4 (GNU M4) 1.4.13
 Copyright (C) 2009 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later
 http://gnu.org/licenses/gpl.html.
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.

 Written by Rene' Seindal.
 #
 # M4=/usr/bin/m4 /usr/bin/bison -d -o pl_gram.with_OpenBSD_4.9_original_m4.c 
 gram.y
 # M4=/usr/bin/gm4 /usr/bin/bison -d -o pl_gram.with_GNU_m4_1.4.13.c gram.y

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


Re: [BUGS] incompatible pointer type

2011-10-19 Thread Tom Lane
Robert Young yay...@gmail.com writes:
 As I tested, if you explicit appoint a union tag, the OpenBSD m4 and
 GNU m4 work identically.
 And This explicit definition just corresponding to the forward-declaration.

 As mentioned in
 http://www.gnu.org/s/bison/manual/html_node/Union-Decl.html
 This feature is a POSIX  extension.
 I don't know what impact to other platform.

 So I suppose this should be the appropriate patch to solve this problem

I don't think we're going to worry too much about making plpgsql cope
with an m4 that's too old to support autoconf, which I gather is the
case from the bison bug report thread I mentioned before.  If you're
going to be changing the source code or working from a git pull, you
need to have reasonably non-broken tools.  We do provide pre-made bison
output in release tarballs, if you don't want to take the responsibility
of having a non-buggy bison available.

regards, tom lane

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


[BUGS] incompatible pointer type

2011-10-18 Thread Robert Young
Platform:
OpenBSD  4.9 GENERIC.MP#819 amd64 Intel(R) Xeon(R) CPU E5620 @ 2.40GHz

Error:
gmake[4]: Entering directory `/tmp/pgxc/git/src/pl/plpgsql/src'
/usr/bin/bison -d  -o pl_gram.c gram.y
gcc -DPGXC -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Wendif-labels -Wformat-security
-fno-strict-aliasing -fwrapv -fpic -DPIC -I. -I.
-I../../../../src/include   -c -o pl_gram.o pl_gram.c
gram.y: In function 'plpgsql_yyparse':
gram.y:875: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:878: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:1229: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:1516: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:1521: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:1562: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:1568: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:1574: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:1580: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:1586: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:1592: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:1636: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:1796: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:1800: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:1807: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y: In function 'tok_is_keyword':
gram.y:2197: error: dereferencing pointer to incomplete type
gram.y:2197: error: dereferencing pointer to incomplete type
gram.y:2198: error: dereferencing pointer to incomplete type
gram.y: In function 'read_datatype':
gram.y:2419: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:2426: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:2443: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:2450: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y: In function 'read_fetch_direction':
gram.y:2624: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:2629: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:2634: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:2639: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:2645: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:2654: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:2663: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:2669: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:2674: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y: In function 'read_raise_options':
gram.y:3370: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:3373: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:3376: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gram.y:3379: warning: passing argument 2 of 'tok_is_keyword' from
incompatible pointer type
gmake[4]: *** [pl_gram.o] Error 1
gmake[4]: Leaving directory `/tmp/pgxc/git/src/pl/plpgsql/src'

CAUSE:
let's inspect an error sample:
wrong1.c :
struct bar;
void foo(struct bar *p)
 {}
typedef struct
 {int a;
 } bar ;
bar u;
int main()
 {foo(u);
  return(0);
 }

# gcc wrong1.c
wrong1.c: In function 'main':
wrong1.c:9: warning: passing argument 1 of 'foo' from incompatible pointer type

BECAUSE: The former bar and the latter bar are NOT RELEVANT.
If we rename the former bar to bar_anthoer ,the compiler would
give the same reply.
wrong2.c :
struct bar_another;
void foo(struct bar_another *p)
 {}
typedef struct
 {int a;
 } bar ;
bar u;
int main()
 {foo(u);
  return(0);
 }

# gcc wrong2.c
wrong2.c: In function 'main':
wrong2.c:9: warning: passing argument 1 of 'foo' from incompatible pointer type

let's fix it.
right.c :
typedef struct
 {int a;
 } bar ;
void foo(bar *p)
 {}
bar u;
int main()
 {foo(u);
  return(0);
 }

FIX:
1.delete YYSTYPE forward-declaration
2.move tok_is_keyword forward-declaration behind YYSTYPE definition
3.delete keyword union in function arguments.
OK.these will eliminate all the warnings.

diff --git a/src/pl/plpgsql/src/gram.y b/src/pl/plpgsql/src/gram.y
index 4e2b705..b632a76 100644
--- a/src/pl/plpgsql/src/gram.y
+++ 

Re: [BUGS] incompatible pointer type

2011-10-18 Thread Tom Lane
Robert Young yay...@gmail.com writes:
 Platform:
 OpenBSD  4.9 GENERIC.MP#819 amd64 Intel(R) Xeon(R) CPU E5620 @ 2.40GHz

Hmm, what version of bison are you using?  Because the ones I've dealt
with emit

typedef union YYSTYPE {
...
} YYSTYPE;

which makes the code correct as-is.  Your proposed patch seems to me
to be making more assumptions about what bison will emit (specifically,
about the ordering of various code blocks) than what we're doing now.

regards, tom lane

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


Re: [BUGS] incompatible pointer type

2011-10-18 Thread Robert Young
# /usr/bin/bison -V
bison (GNU Bison) 2.3
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
From:
http://ftp.openbsd.org/pub/OpenBSD/4.9/packages/amd64/bison-2.3.tgz

Sure! my pl_gram.c generated by this version of bison is :

403 typedef union
404 #line 115 gram.y
405 {
406 core_YYSTYPEcore_yystype;
   .
454 PLpgSQL_case_when   *casewhen;
455 }
456 /* Line 193 of yacc.c.  */
457 #line 458 pl_gram.c
458 YYSTYPE;

and cause the generated pl_gram.c problematic.


On Tue, Oct 18, 2011 at 18:22, Tom Lane t...@sss.pgh.pa.us wrote:
 Robert Young yay...@gmail.com writes:
 Platform:
 OpenBSD  4.9 GENERIC.MP#819 amd64 Intel(R) Xeon(R) CPU E5620 @ 2.40GHz

 Hmm, what version of bison are you using?  Because the ones I've dealt
 with emit

 typedef union YYSTYPE {
        ...
 } YYSTYPE;

 which makes the code correct as-is.  Your proposed patch seems to me
 to be making more assumptions about what bison will emit (specifically,
 about the ordering of various code blocks) than what we're doing now.

                        regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


Re: [BUGS] incompatible pointer type

2011-10-18 Thread Tom Lane
Robert Young yay...@gmail.com writes:
 On Tue, Oct 18, 2011 at 18:22, Tom Lane t...@sss.pgh.pa.us wrote:
 Hmm, what version of bison are you using?

 # /usr/bin/bison -V
 bison (GNU Bison) 2.3
 Written by Robert Corbett and Richard Stallman.

 Copyright (C) 2006 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 #
 From:
 http://ftp.openbsd.org/pub/OpenBSD/4.9/packages/amd64/bison-2.3.tgz

Interesting.  I've got bison 2.3 on my Mac laptop, and it does what I
expect (ie, it emits typedef union YYSTYPE ...).  So do the oldest and
newest bison versions I have handy (1.875 and 2.4.3), and both of their
manuals specify that this is the expected behavior -- see
http://www.gnu.org/s/bison/manual/html_node/Union-Decl.html
about halfway down the page.

A little bit of googling suggests that this is a bug or incompatibility
with openbsd's m4 (a tool that bison relies on):
http://comments.gmane.org/gmane.comp.parsers.bison.bugs/2708
That thread petered out without any clear resolution, but maybe you
should check for m4 updates, or try installing GNU m4.

regards, tom lane

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


Re: [BUGS] incompatible pointer type

2011-10-18 Thread Tom Lane
I wrote:
 A little bit of googling suggests that this is a bug or incompatibility
 with openbsd's m4 (a tool that bison relies on):
 http://comments.gmane.org/gmane.comp.parsers.bison.bugs/2708

Scratch that: closer reading of the page says that the complainant was not
using some openbsd-specific copy of m4, but GNU m4 1.4.4, and that the
problem is not reproducible with newer versions of m4.  So what it seems
to boil down to is get a newer m4.  Especially if you've got 1.4.4.

regards, tom lane

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


Re: [BUGS] incompatible pointer type

2011-10-18 Thread Robert Young
Perfect!
I've update my m4 to version 1.4.13
from:
http://ftp.openbsd.org/pub/OpenBSD/4.9/packages/amd64/m4-1.4.13.tgz
the problem solved perfectly!
Thank You !!!

# /usr/bin/gm4 --version
m4 (GNU M4) 1.4.13
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Rene' Seindal.
#
# M4=/usr/bin/m4 /usr/bin/bison -d -o
pl_gram.with_OpenBSD_4.9_original_m4.c gram.y
# M4=/usr/bin/gm4 /usr/bin/bison -d -o pl_gram.with_GNU_m4_1.4.13.c gram.y
# diff -u pl_gram.with_OpenBSD_4.9_original_m4.c pl_gram.with_GNU_m4_1.4.13.c
--- pl_gram.with_OpenBSD_4.9_original_m4.c  Wed Oct 19 04:55:38 2011
+++ pl_gram.with_GNU_m4_1.4.13.cWed Oct 19 04:55:46 2011
@@ -400,7 +400,7 @@
 #endif

 #if ! defined YYSTYPE  ! defined YYSTYPE_IS_DECLARED
-typedef union
+typedef union YYSTYPE
 #line 115 gram.y
 {
core_YYSTYPEcore_yystype;
@@ -453,8 +453,8 @@
PLpgSQL_stmt_fetch  *fetch;
PLpgSQL_case_when   *casewhen;
 }
-/* Line 193 of yacc.c.  */
-#line 458 pl_gram.with_OpenBSD_4.9_original_m4.c
+/* Line 187 of yacc.c.  */
+#line 458 pl_gram.with_GNU_m4_1.4.13.c
YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
@@ -479,7 +479,7 @@


 /* Line 216 of yacc.c.  */
-#line 483 pl_gram.with_OpenBSD_4.9_original_m4.c
+#line 483 pl_gram.with_GNU_m4_1.4.13.c

 #ifdef short
 # undef short
@@ -4077,7 +4077,7 @@


 /* Line 1267 of yacc.c.  */
-#line 4081 pl_gram.with_OpenBSD_4.9_original_m4.c
+#line 4081 pl_gram.with_GNU_m4_1.4.13.c
   default: break;
 }
   YY_SYMBOL_PRINT (- $$ =, yyr1[yyn], yyval, yyloc);
#

On Wed, Oct 19, 2011 at 03:01, Tom Lane t...@sss.pgh.pa.us wrote:
 I wrote:
 A little bit of googling suggests that this is a bug or incompatibility
 with openbsd's m4 (a tool that bison relies on):
 http://comments.gmane.org/gmane.comp.parsers.bison.bugs/2708

 Scratch that: closer reading of the page says that the complainant was not
 using some openbsd-specific copy of m4, but GNU m4 1.4.4, and that the
 problem is not reproducible with newer versions of m4.  So what it seems
 to boil down to is get a newer m4.  Especially if you've got 1.4.4.

                        regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


Re: [BUGS] incompatible pointer type

2011-10-18 Thread Tom Lane
Robert Young yay...@gmail.com writes:
 I've update my m4 to version 1.4.13
 from:
 http://ftp.openbsd.org/pub/OpenBSD/4.9/packages/amd64/m4-1.4.13.tgz
 the problem solved perfectly!

Just for the archives' sake, can you confirm which m4 version you had
before?

regards, tom lane

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


Re: [BUGS] incompatible pointer type

2011-10-18 Thread Robert Young
So,I think it'd better to check the m4 compatiblity in ./configure

On Wed, Oct 19, 2011 at 05:10, Robert Young yay...@gmail.com wrote:
 Perfect!
 I've update my m4 to version 1.4.13
 from:
 http://ftp.openbsd.org/pub/OpenBSD/4.9/packages/amd64/m4-1.4.13.tgz
 the problem solved perfectly!
 Thank You !!!


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


Re: [BUGS] incompatible pointer type

2011-10-18 Thread Robert Young
It is hard to figure out,but I inspect the source code,told me:
http://ftp.openbsd.org/pub/OpenBSD/4.9/sys.tar.gz:/usr.bin/m4/PSD.doc/m4.ms:
Line35: m4.ms   6.3 (Berkeley) 6/5/93

On Wed, Oct 19, 2011 at 05:12, Tom Lane t...@sss.pgh.pa.us wrote:
 Robert Young yay...@gmail.com writes:
 I've update my m4 to version 1.4.13
 from:
 http://ftp.openbsd.org/pub/OpenBSD/4.9/packages/amd64/m4-1.4.13.tgz
 the problem solved perfectly!

 Just for the archives' sake, can you confirm which m4 version you had
 before?

                        regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs