Skip to content

Commit f7d8362

Browse files
author
Michael Meskes
committed
Fixed double definition of ecpg_compat_mode.
1 parent 9e9d8d5 commit f7d8362

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

src/interfaces/ecpg/ecpglib/connect.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.3 2003/04/08 12:34:25 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.4 2003/05/02 14:43:25 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

@@ -11,8 +11,6 @@
1111
static struct connection *all_connections = NULL,
1212
*actual_connection = NULL;
1313

14-
extern enum COMPAT_MODE ecpg_compat_mode;
15-
1614
struct connection *
1715
ECPGget_connection(const char *connection_name)
1816
{
@@ -259,6 +257,20 @@ ECPGnoticeProcessor(void *arg, const char *message)
259257
sqlca.sqlwarn[0] = 'W';
260258
}
261259

260+
/* this contains some quick hacks, needs to be cleaned up, but it works */
261+
bool
262+
ECPGconnect_informix(int lineno, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
263+
{
264+
char *informix_name = (char *)name, *envname;
265+
266+
/* Informix uses an environment variable DBPATH that overrides
267+
* the connection parameters given here */
268+
envname = getenv("DBPATH");
269+
if (envname)
270+
informix_name = envname;
271+
return (ECPGconnect(lineno, informix_name, user, passwd, connection_name, autocommit));
272+
}
273+
262274
/* this contains some quick hacks, needs to be cleaned up, but it works */
263275
bool
264276
ECPGconnect(int lineno, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)
@@ -269,26 +281,13 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
269281
*tmp,
270282
*port = NULL,
271283
*realname = NULL,
272-
*options = NULL,
273-
*envname;
284+
*options = NULL;
274285

275286
ECPGinit_sqlca();
276287

277288
if ((this = (struct connection *) ECPGalloc(sizeof(struct connection), lineno)) == NULL)
278289
return false;
279290

280-
if (ecpg_compat_mode == ECPG_COMPAT_INFORMIX)
281-
{
282-
/* Informix uses an environment variable DBPATH that overrides
283-
* the connection parameters given here */
284-
envname = getenv("DBPATH");
285-
if (envname)
286-
{
287-
free(dbname);
288-
dbname=strdup(envname);
289-
}
290-
}
291-
292291
if (dbname == NULL && connection_name == NULL)
293292
connection_name = "DEFAULT";
294293

src/interfaces/ecpg/include/ecpglib.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ void ECPGdebug(int, FILE *);
4242
bool ECPGstatus(int, const char *);
4343
bool ECPGsetcommit(int, const char *, const char *);
4444
bool ECPGsetconn(int, const char *);
45+
bool ECPGconnect_informix(int, const char *, const char *, const char *, const char *, int);
4546
bool ECPGconnect(int, const char *, const char *, const char *, const char *, int);
4647
bool ECPGdo(int, const char *, char *,...);
4748
bool ECPGtrans(int, const char *, const char *);

src/interfaces/ecpg/preproc/ecpg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.67 2003/05/01 17:16:57 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.68 2003/05/02 14:43:25 meskes Exp $ */
22

33
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
44
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
@@ -339,7 +339,7 @@ main(int argc, char *const argv[])
339339
lex_init();
340340

341341
/* we need several includes */
342-
fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These four include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n#line 1 \"%s\"\nenum COMPAT_MODE ecpg_compat_mode=%d;\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename, compat);
342+
fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/* These four include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n#include <ecpgerrno.h>\n#include <sqlca.h>\n#line 1 \"%s\"\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL, input_filename);
343343

344344
/* add some compatibility headers */
345345
if (compat == ECPG_COMPAT_INFORMIX)

src/interfaces/ecpg/preproc/preproc.y

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.215 2003/03/27 14:29:17 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.216 2003/05/02 14:43:25 meskes Exp $ */
22

33
/* Copyright comment */
44
%{
@@ -528,7 +528,10 @@ stmt: AlterDatabaseSetStmt { output_statement($1, 0, connection); }
528528
if (connection)
529529
mmerror(PARSE_ERROR, ET_ERROR, "no at option for connect statement.\n");
530530

531-
fprintf(yyout, "{ ECPGconnect(__LINE__, %s, %d); ", $1, autocommit);
531+
if (compat == ECPG_COMPAT_INFORMIX)
532+
fprintf(yyout, "{ ECPGconnect_informix(__LINE__, %s, %d); ", $1, autocommit);
533+
else
534+
fprintf(yyout, "{ ECPGconnect(__LINE__, %s, %d); ", $1, autocommit);
532535
reset_variables();
533536
whenever_action(2);
534537
free($1);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy