dbTalk Databases Forums  

[BUGS] Bug in ECPG preprocessor

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] Bug in ECPG preprocessor in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Sergey N. Yatskevich
 
Posts: n/a

Default [BUGS] Bug in ECPG preprocessor - 05-26-2004 , 05:01 PM






--=-1rdjJYBWDEuftI1xl6Ag
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

ECPG preprocessor for PostgreSQL 7.4.1, 7.4.2 doubles const,
volatile, static, and register keywords before variables,
declared as VARCHAR.

I attach to this mail example for this, and patch for PostgreSQL
7.4.1, that solves this problem (this patch also applicable to
PostgreSQL 7.4.2 too)

--
Sergey N. Yatskevich <syatskevich (AT) n21lab (DOT) gosniias.msk.ru>
GosNIIAS

--=-1rdjJYBWDEuftI1xl6Ag
Content-Disposition: attachment; filename=start.sh
Content-Type: application/x-shellscript; name=start.sh
Content-Transfer-Encoding: 7bit

#!/bin/bash
################################################## ###################
INC=`pg_config --includedir`
CFLAGS="-I$INC"
LDFLAG='-lpq'
ECPGFLAG="-t -I$INC"
ecpg $ECPGFLAG test.pgc -o test.cpp
g++ $CFLAGS -c test.cpp
g++ -o TEST test.o $LDFLAGS
################################################## ###################

--=-1rdjJYBWDEuftI1xl6Ag
Content-Disposition: attachment; filename=test.pgc
Content-Type: text/plain; name=test.pgc; charset=KOI8-R
Content-Transfer-Encoding: 7bit

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ecpgtype.h>
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <math.h>


EXEC SQL INCLUDE sqlca;
EXEC SQL BEGIN DECLARE SECTION;
int n;
extern int i, y;
VARCHAR vc1[128];
extern VARCHAR vc2[128];
volatile VARCHAR vc3[128];
const VARCHAR vc4[128] = {10, "0123456789"};

unsigned char bt1[128];
extern unsigned char bt2[128];

unsigned char btout1[128];
extern unsigned char btout2[128];
unsigned int lbt, lbt1, lbt2;
int cint;
extern double cdouble;
EXEC SQL END DECLARE SECTION;

///////////////////////////////////////////////////////////////////////////////////////////////////////
int main ( int argc, char *argv[] )
///////////////////////////////////////////////////////////////////////////////////////////////////////
{
sprintf(vc1.arr,"varchar1");
printf("TEST: %s %s\n",vc1.arr,vc4.arr);
}

--=-1rdjJYBWDEuftI1xl6Ag
Content-Disposition: attachment; filename=ecpg-7.4.1.patch
Content-Type: text/x-patch; name=ecpg-7.4.1.patch; charset=KOI8-R
Content-Transfer-Encoding: 7bit

Index: src/interfaces/ecpg/preproc/preproc.y
================================================== =================
RCS file: /mnt/disk/cvsroot/pgsql/src/interfaces/ecpg/preproc/preproc.y,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 preproc.y
--- src/interfaces/ecpg/preproc/preproc.y 25 Dec 2003 10:58:24 -0000 1.1.1.3
+++ src/interfaces/ecpg/preproc/preproc.y 24 May 2004 14:13:42 -0000
@@ -19,7 +19,6 @@
static int QueryIsRule = 0, FoundInto = 0;
static int initializer = 0;
static struct this_type actual_type[STRUCT_DEPTH];
-static char *actual_storage[STRUCT_DEPTH];
static char *actual_startline[STRUCT_DEPTH];

/* temporarily store struct members while creating the data structure */
@@ -4419,6 +4418,8 @@
actual_type[struct_level].type_dimension = $2.type_dimension;
actual_type[struct_level].type_index = $2.type_index;
actual_type[struct_level].type_sizeof = $2.type_sizeof;
+
+ actual_startline[struct_level] = hashline_number();
}
variable_list ';'
{
@@ -4430,7 +4431,6 @@
actual_type[struct_level].type_dimension = $1.type_dimension;
actual_type[struct_level].type_index = $1.type_index;
actual_type[struct_level].type_sizeof = $1.type_sizeof;
- actual_storage[struct_level] = EMPTY;

actual_startline[struct_level] = hashline_number();
}
@@ -4687,6 +4687,8 @@
actual_type[struct_level].type_dimension = $2.type_dimension;
actual_type[struct_level].type_index = $2.type_index;
actual_type[struct_level].type_sizeof = $2.type_sizeof;
+
+ actual_startline[struct_level] = hashline_number();
}
variable_list ';'
{
@@ -4698,7 +4700,6 @@
actual_type[struct_level].type_dimension = $1.type_dimension;
actual_type[struct_level].type_index = $1.type_index;
actual_type[struct_level].type_sizeof = $1.type_sizeof;
- actual_storage[struct_level] = EMPTY;

actual_startline[struct_level] = hashline_number();
}
@@ -4714,18 +4715,15 @@

storage_declaration: storage_clause storage_modifier
{
- actual_storage[struct_level] = cat2_str(mm_strdup($1), mm_strdup($2));
- actual_startline[struct_level] = hashline_number();
+ $$ = cat2_str ($1, $2);
}
Quote:
storage_clause
{
- actual_storage[struct_level] = mm_strdup($1);
- actual_startline[struct_level] = hashline_number();
+ $$ = $1;
}
Quote:
storage_modifier
{
- actual_storage[struct_level] = mm_strdup($1);
- actual_startline[struct_level] = hashline_number();
+ $$ = $1;
}
;

@@ -4951,7 +4949,7 @@

ECPGfree_struct_member(struct_member_list[struct_level]);
struct_member_list[struct_level] = NULL;
- free(actual_storage[struct_level--]);
+ struct_level--;
if (strncmp($1.su, "struct", sizeof("struct")-1) == 0)
su_type.type_enum = ECPGt_struct;
else
@@ -5001,7 +4999,7 @@
{
ECPGfree_struct_member(struct_member_list[struct_level]);
struct_member_list[struct_level] = NULL;
- free(actual_storage[struct_level--]);
+ struct_level--;
$$ = cat_str(4, $1, make_str("{"), $4, make_str("}"));
}
;
@@ -5126,9 +5124,9 @@
mmerror(PARSE_ERROR, ET_ERROR, "pointer to varchar are not implemented");

if (strcmp(dimension, "0") == 0)
- $$ = cat_str(7, mm_strdup(actual_storage[struct_level]), make2_str(make_str(" struct varchar_"), mm_strdup($2)), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } *"), mm_strdup($2), $4);
+ $$ = cat_str(6, make2_str(make_str(" struct varchar_"), mm_strdup($2)), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } *"), mm_strdup($2), $4);
else
- $$ = cat_str(8, mm_strdup(actual_storage[struct_level]), make2_str(make_str(" struct varchar_"), mm_strdup($2)), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } "), mm_strdup($2), mm_strdup(dim), $4);
+ $$ = cat_str(7, make2_str(make_str(" struct varchar_"), mm_strdup($2)), make_str(" { int len; char arr["), mm_strdup(length), make_str("]; } "), mm_strdup($2), mm_strdup(dim), $4);
break;

case ECPGt_char:

--=-1rdjJYBWDEuftI1xl6Ag
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

--=-1rdjJYBWDEuftI1xl6Ag--




Reply With Quote
  #2  
Old   
Bruce Momjian
 
Posts: n/a

Default Re: [BUGS] Bug in ECPG preprocessor - 06-09-2004 , 09:29 PM







Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------


Sergey N. Yatskevich wrote:
Quote:
ECPG preprocessor for PostgreSQL 7.4.1, 7.4.2 doubles const,
volatile, static, and register keywords before variables,
declared as VARCHAR.

I attach to this mail example for this, and patch for PostgreSQL
7.4.1, that solves this problem (this patch also applicable to
PostgreSQL 7.4.2 too)

--
Sergey N. Yatskevich <syatskevich (AT) n21lab (DOT) gosniias.msk.ru
GosNIIAS
[ Attachment, skipping... ]

[ Attachment, skipping... ]

[ Attachment, skipping... ]

Quote:
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html
--
Bruce Momjian | http://candle.pha.pa.us
pgman (AT) candle (DOT) pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
  #3  
Old   
Bruce Momjian
 
Posts: n/a

Default Re: [BUGS] Bug in ECPG preprocessor - 06-11-2004 , 12:40 PM




OK, patch applied to 7.4.X and current. Michael Meskes reviewed the
patch. Thanks.

---------------------------------------------------------------------------

Sergey N. Yatskevich wrote:
Quote:
ECPG preprocessor for PostgreSQL 7.4.1, 7.4.2 doubles const,
volatile, static, and register keywords before variables,
declared as VARCHAR.

I attach to this mail example for this, and patch for PostgreSQL
7.4.1, that solves this problem (this patch also applicable to
PostgreSQL 7.4.2 too)

--
Sergey N. Yatskevich <syatskevich (AT) n21lab (DOT) gosniias.msk.ru
GosNIIAS
[ Attachment, skipping... ]

[ Attachment, skipping... ]

[ Attachment, skipping... ]

Quote:
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html
--
Bruce Momjian | http://candle.pha.pa.us
pgman (AT) candle (DOT) pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.