Bug 143467 - precompiler error - uses one definition only
precompiler error - uses one definition only
Status: CLOSED CURRENTRELEASE
Product: Fedora
Classification: Fedora
Component: postgresql (Show other bugs)
3
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Tom Lane
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-12-21 03:38 EST by Juhani Försti
Modified: 2013-07-02 23:03 EDT (History)
2 users (show)

See Also:
Fixed In Version: postgresql-8.0.0-1
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-09-30 15:08:20 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Juhani Försti 2004-12-21 03:38:33 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5)
Gecko/20041107 Firefox/1.0

Description of problem:
I installed FC3 and I tried then to use postgresql-7.4.6 from the box.
Precompiler didn't use include files right in database table
definitions. If I had in include files two (or more) definitions,
which used same definition for field length it used only the first
one. Both postgresql-7.4.6-1.FC3.1 and postgresql-7.4.6-1.FC3.2 worked
likewise.

ex.
...
char address[ ADDRESSLEN ];
char address2[ ADDRESSLEN ];
...

became after precompilation
....
  char address [ 40 ];
  char address2 [ ADDRESSLEN ];
...

(Downgraded version ie postgresql-7.3.8-3PGDG worked fine)


Version-Release number of selected component (if applicable):
postgresql-7.4.6-1.FC3.1 and postgresql-7.4.6-1.FC3.2

How reproducible:
Always

Steps to Reproduce:
1. modify file to precompile 
2. precompile ie make it
3. look at precompiled file
    

Additional info:
Comment 1 Michael Meskes 2004-12-22 03:56:13 EST
I'm not exactly sure what you are doing. From your bug report it is
not clear to me how you define the symbol, what file you are including
and in which type of statement you do not get the correct results.

I tried the following test case:

exec sql define A 40;

exec sql begin declare section;
char address[ A ];
char address2[ A ];
exec sql end declare section;

and compiled with "ecpg <file>". The result is:

/* Processed by ecpg (3.2.0) */
/* These include files are added by the preprocessor */
#include <ecpgtype.h>
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
/* End of automatic include section */
#line 1 "a.pgc"


/* exec sql begin declare section */



#line 4 "a.pgc"
 char  address [ 40 ]   ;

#line 5 "a.pgc"
 char  address2 [ 40 ]   ;
/* exec sql end declare section */
#line 6 "a.pgc"

As you see, both line have been replaced. But then I just tried with
ecpg version 3.2.0 which has yet to be released. :-)

Could you please send me some more details? Best would be the source
file you are using and the commandline options you use for
compilation. If this is still present in 3.2.0 I'd surely like to fix
it before we release.

Michael
Comment 2 Juhani Försti 2004-12-23 01:06:03 EST
test.ec -file contains following:
EXEC SQL INCLUDE sqlca;
EXEC SQL INCLUDE stdecinc3.h;

stdecinc3.h file contains:
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL include a_len.xsh;
EXEC SQL END DECLARE SECTION;

EXEC SQL INCLUDE a_tbl.xsh;

a_len.xsh contains:
EXEC SQL define ADDRESSLEN 40;

a_tbl.xsh contains:
#1 "<built-in>"
#1 "<command line>"
#1 "<stdin>"
#23 "<stdin>"

EXEC SQL TYPE TRCUSTOMER is struct {
char address1[ADDRESSLEN];
char address2[ADDRESSLEN];
};


after using command:
ecpg test.ec -o test.c

test.c contains following:
/* Processed by ecpg (3.1.1) */
/* These include files are added by the preprocessor */
#include <ecpgtype.h>
#include <ecpglib.h>
#include <ecpgerrno.h>
#include <sqlca.h>
#line 1 "test.ec"
/* End of automatic include section */



#line 1 "/usr/include/sqlca.h"
#ifndef POSTGRES_SQLCA_H
#define POSTGRES_SQLCA_H

#ifndef DLLIMPORT
#if defined(__CYGWIN__) || defined(WIN32)
#define DLLIMPORT __declspec (dllimport)
#else
#define DLLIMPORT
#endif   /* __CYGWIN__ */
#endif   /* DLLIMPORT */

#define SQLERRMC_LEN	70

#ifdef __cplusplus
extern		"C"
{
#endif

struct sqlca_t
{
	char		sqlcaid[8];
	long		sqlabc;
	long		sqlcode;
	struct
	{
		int			sqlerrml;
		char		sqlerrmc[SQLERRMC_LEN];
	}			sqlerrm;
	char		sqlerrp[8];
	long		sqlerrd[6];
	/* Element 0: empty						*/
	/* 1: OID of processed tuple if applicable			*/
	/* 2: number of rows processed				*/
	/* after an INSERT, UPDATE or				*/
	/* DELETE statement					*/
	/* 3: empty						*/
	/* 4: empty						*/
	/* 5: empty						*/
	char		sqlwarn[8];
	/* Element 0: set to 'W' if at least one other is 'W'	*/
	/* 1: if 'W' at least one character string		*/
	/* value was truncated when it was			*/
	/* stored into a host variable.				*/

	/*
	 * 2: if 'W' a (hopefully) non-fatal notice occurred
	 */	/* 3: empty */
	/* 4: empty						*/
	/* 5: empty						*/
	/* 6: empty						*/
	/* 7: empty						*/

	char		sqlstate[5];
};

struct sqlca_t *ECPGget_sqlca(void);

#ifndef POSTGRES_ECPG_INTERNAL
#define sqlca (*ECPGget_sqlca())
#endif

#ifdef __cplusplus
}
#endif

#endif

#line 3 "test.ec"


#line 1 "./stdecinc3.h"
/* exec sql begin declare section */

#line 1 "./a_len.xsh"



#line 2 "./stdecinc3.h"

/* exec sql end declare section */
#line 3 "./stdecinc3.h"



#line 1 "./a_tbl.xsh"
#1 "<built-in>"
#1 "<command line>"
#1 "<stdin>"
#23 "<stdin>"

/* exec sql type TRCUSTOMER is struct { 
#line 7 "./a_tbl.xsh"
 char  address1 [ 40 ]   ;
 
#line 8 "./a_tbl.xsh"
 char  address2 [ ADDRESSLEN ]   ;
 }   */
#line 9 "./a_tbl.xsh"


#line 5 "./stdecinc3.h"




#line 4 "test.ec"

Above address2 ha wrong len ie ADDRESSLEN. First I used
postgresql-7.4.6-1.FC3.1 -version and then I rpm:ed
postgresql-7.4.6-1.FC3.2 but the resuilt was same. They both had same
precompiler. I rpm:ed postgresql, postgresql-devel, postgresql-docs,
postgresql-server and postgresql-libs  with their proper versions.
Version postgresql-XXXX-7.3.8-3PGDG works instead ok.
Comment 3 Michael Meskes 2004-12-23 05:48:14 EST
Thanks for the report and the additional files. I just committed a fix
to CVS that should be included in the 8.0 release. Please tell me if
it does not fix your problem, but then the test case worked correctly.

Michael
Comment 4 Tom Lane 2005-09-30 15:08:20 EDT
Closing out this bug report since PG 8.0 is now available in Fedora Core 4.

Note You need to log in before you can comment on or make changes to this bug.