Skip to content

Commit 150131d

Browse files
author
Michael Meskes
committed
- Made several variables "const char *" instead of "char *" as proposed by Qingqing Zhou <zhouqq@cs.toronto.edu>.
- Replaced all strdup() calls by ECPGstrdup(). - Set ecpg library version to 5.2. - Set ecpg version to 4.2.1.
1 parent 339fbbb commit 150131d

File tree

8 files changed

+49
-40
lines changed

8 files changed

+49
-40
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1952,3 +1952,11 @@ Wed Oct 5 16:57:42 CEST 2005
19521952
- Set ecpg library version to 5.1.
19531953
- Set ecpg version to 4.1.1.
19541954

1955+
Wed Nov 30 12:49:13 CET 2005
1956+
1957+
- Made several variables "const char *" instead of "char *" as
1958+
proposed by Qingqing Zhou <zhouqq@cs.toronto.edu>.
1959+
- Replaced all strdup() calls by ECPGstrdup().
1960+
- Set ecpg library version to 5.2.
1961+
- Set ecpg version to 4.2.1.
1962+

src/interfaces/ecpg/ecpglib/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.33 2005/03/14 17:27:50 momjian Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.34 2005/11/30 12:49:49 meskes Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global
1414

1515
NAME= ecpg
1616
SO_MAJOR_VERSION= 5
17-
SO_MINOR_VERSION= 1
17+
SO_MINOR_VERSION= 2
1818
DLTYPE= library
1919

2020
override CPPFLAGS := -DFRONTEND -I$(top_srcdir)/src/interfaces/ecpg/include \

src/interfaces/ecpg/ecpglib/connect.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.26 2005/10/15 02:49:47 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.27 2005/11/30 12:49:49 meskes Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -265,7 +265,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
265265
struct sqlca_t *sqlca = ECPGget_sqlca();
266266
enum COMPAT_MODE compat = c;
267267
struct connection *this;
268-
char *dbname = name ? strdup(name) : NULL,
268+
char *dbname = name ? ECPGstrdup(name, lineno) : NULL,
269269
*host = NULL,
270270
*tmp,
271271
*port = NULL,
@@ -287,7 +287,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
287287
if (envname)
288288
{
289289
ECPGfree(dbname);
290-
dbname = strdup(envname);
290+
dbname = ECPGstrdup(envname, lineno);
291291
}
292292

293293
}
@@ -307,17 +307,17 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
307307
tmp = strrchr(dbname, ':');
308308
if (tmp != NULL) /* port number given */
309309
{
310-
port = strdup(tmp + 1);
310+
port = ECPGstrdup(tmp + 1, lineno);
311311
*tmp = '\0';
312312
}
313313

314314
tmp = strrchr(dbname, '@');
315315
if (tmp != NULL) /* host name given */
316316
{
317-
host = strdup(tmp + 1);
317+
host = ECPGstrdup(tmp + 1, lineno);
318318
*tmp = '\0';
319319
}
320-
realname = strdup(dbname);
320+
realname = ECPGstrdup(dbname, lineno);
321321
}
322322
else if (strncmp(dbname, "tcp:", 4) == 0 || strncmp(dbname, "unix:", 5) == 0)
323323
{
@@ -345,14 +345,14 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
345345
tmp = strrchr(dbname + offset, '?');
346346
if (tmp != NULL) /* options given */
347347
{
348-
options = strdup(tmp + 1);
348+
options = ECPGstrdup(tmp + 1, lineno);
349349
*tmp = '\0';
350350
}
351351

352352
tmp = last_dir_separator(dbname + offset);
353353
if (tmp != NULL) /* database name given */
354354
{
355-
realname = strdup(tmp + 1);
355+
realname = ECPGstrdup(tmp + 1, lineno);
356356
*tmp = '\0';
357357
}
358358

@@ -365,7 +365,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
365365
if ((tmp2 = strchr(tmp + 1, ':')) != NULL)
366366
{
367367
*tmp2 = '\0';
368-
host = strdup(tmp + 1);
368+
host = ECPGstrdup(tmp + 1, lineno);
369369
if (strncmp(dbname, "unix:", 5) != 0)
370370
{
371371
ECPGlog("connect: socketname %s given for TCP connection in line %d\n", host, lineno);
@@ -384,7 +384,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
384384
}
385385
}
386386
else
387-
port = strdup(tmp + 1);
387+
port = ECPGstrdup(tmp + 1, lineno);
388388
}
389389

390390
if (strncmp(dbname, "unix:", 5) == 0)
@@ -407,14 +407,14 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
407407
}
408408
}
409409
else
410-
host = strdup(dbname + offset);
410+
host = ECPGstrdup(dbname + offset, lineno);
411411

412412
}
413413
else
414-
realname = strdup(dbname);
414+
realname = ECPGstrdup(dbname, lineno);
415415
}
416416
else
417-
realname = strdup(dbname);
417+
realname = ECPGstrdup(dbname, lineno);
418418
}
419419
else
420420
realname = NULL;

src/interfaces/ecpg/ecpglib/descriptor.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* dynamic SQL support routines
22
*
3-
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.12 2004/08/29 05:06:59 momjian Exp $
3+
* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.13 2005/11/30 12:49:49 meskes Exp $
44
*/
55

66
#define POSTGRES_ECPG_INTERNAL
@@ -49,7 +49,7 @@ ECPGDynamicType_DDT(Oid type)
4949
}
5050

5151
bool
52-
ECPGget_desc_header(int lineno, char *desc_name, int *count)
52+
ECPGget_desc_header(int lineno, const char *desc_name, int *count)
5353
{
5454
PGresult *ECPGresult;
5555
struct sqlca_t *sqlca = ECPGget_sqlca();
@@ -188,7 +188,7 @@ get_char_item(int lineno, void *var, enum ECPGttype vartype, char *value, int va
188188
}
189189

190190
bool
191-
ECPGget_desc(int lineno, char *desc_name, int index,...)
191+
ECPGget_desc(int lineno, const char *desc_name, int index,...)
192192
{
193193
va_list args;
194194
PGresult *ECPGresult;
@@ -383,7 +383,7 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
383383

384384
/* Make sure we do NOT honor the locale for numeric input */
385385
/* since the database gives the standard decimal point */
386-
oldlocale = strdup(setlocale(LC_NUMERIC, NULL));
386+
oldlocale = ECPGstrdup(setlocale(LC_NUMERIC, NULL), lineno);
387387
setlocale(LC_NUMERIC, "C");
388388

389389
memset(&stmt, 0, sizeof stmt);
@@ -431,7 +431,7 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
431431
}
432432

433433
bool
434-
ECPGset_desc_header(int lineno, char *desc_name, int count)
434+
ECPGset_desc_header(int lineno, const char *desc_name, int count)
435435
{
436436
struct descriptor *desc;
437437

@@ -452,7 +452,7 @@ ECPGset_desc_header(int lineno, char *desc_name, int count)
452452
}
453453

454454
bool
455-
ECPGset_desc(int lineno, char *desc_name, int index,...)
455+
ECPGset_desc(int lineno, const char *desc_name, int index,...)
456456
{
457457
va_list args;
458458
struct descriptor *desc;

src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.43 2005/10/15 02:49:47 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.44 2005/11/30 12:49:49 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -141,15 +141,15 @@ ECPGget_variable(va_list APREF, enum ECPGttype type, struct variable * var, bool
141141
* ind_offset - indicator offset
142142
*/
143143
static bool
144-
create_statement(int lineno, int compat, int force_indicator, struct connection * connection, struct statement ** stmt, char *query, va_list ap)
144+
create_statement(int lineno, int compat, int force_indicator, struct connection * connection, struct statement ** stmt, const char *query, va_list ap)
145145
{
146146
struct variable **list = &((*stmt)->inlist);
147147
enum ECPGttype type;
148148

149149
if (!(*stmt = (struct statement *) ECPGalloc(sizeof(struct statement), lineno)))
150150
return false;
151151

152-
(*stmt)->command = query;
152+
(*stmt)->command = ECPGstrdup(query, lineno);
153153
(*stmt)->connection = connection;
154154
(*stmt)->lineno = lineno;
155155
(*stmt)->compat = compat;
@@ -224,6 +224,7 @@ free_statement(struct statement * stmt)
224224
return;
225225
free_variable(stmt->inlist);
226226
free_variable(stmt->outlist);
227+
ECPGfree(stmt->command);
227228
ECPGfree(stmt);
228229
}
229230

@@ -1359,7 +1360,7 @@ ECPGexecute(struct statement * stmt)
13591360
}
13601361

13611362
bool
1362-
ECPGdo(int lineno, int compat, int force_indicator, const char *connection_name, char *query,...)
1363+
ECPGdo(int lineno, int compat, int force_indicator, const char *connection_name, const char *query,...)
13631364
{
13641365
va_list args;
13651366
struct statement *stmt;
@@ -1369,7 +1370,7 @@ ECPGdo(int lineno, int compat, int force_indicator, const char *connection_name,
13691370

13701371
/* Make sure we do NOT honor the locale for numeric input/output */
13711372
/* since the database wants the standard decimal point */
1372-
oldlocale = strdup(setlocale(LC_NUMERIC, NULL));
1373+
oldlocale = ECPGstrdup(setlocale(LC_NUMERIC, NULL), lineno);
13731374
setlocale(LC_NUMERIC, "C");
13741375

13751376
if (!ECPGinit(con, connection_name, lineno))

src/interfaces/ecpg/ecpglib/prepare.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.14 2005/10/15 02:49:47 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.15 2005/11/30 12:49:49 meskes Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -60,7 +60,7 @@ replace_variables(char *text)
6060

6161
/* handle the EXEC SQL PREPARE statement */
6262
bool
63-
ECPGprepare(int lineno, char *name, char *variable)
63+
ECPGprepare(int lineno, const char *name, const char *variable)
6464
{
6565
struct statement *stmt;
6666
struct prepared_statement *this;
@@ -112,7 +112,7 @@ ECPGprepare(int lineno, char *name, char *variable)
112112

113113
/* handle the EXEC SQL DEALLOCATE PREPARE statement */
114114
bool
115-
ECPGdeallocate(int lineno, int c, char *name)
115+
ECPGdeallocate(int lineno, int c, const char *name)
116116
{
117117
bool ret = ECPGdeallocate_one(lineno, name);
118118
enum COMPAT_MODE compat = c;
@@ -133,7 +133,7 @@ ECPGdeallocate(int lineno, int c, char *name)
133133
}
134134

135135
bool
136-
ECPGdeallocate_one(int lineno, char *name)
136+
ECPGdeallocate_one(int lineno, const char *name)
137137
{
138138
struct prepared_statement *this,
139139
*prev;

src/interfaces/ecpg/include/ecpglib.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ bool ECPGstatus(int, const char *);
4848
bool ECPGsetcommit(int, const char *, const char *);
4949
bool ECPGsetconn(int, const char *);
5050
bool ECPGconnect(int, int, const char *, const char *, const char *, const char *, int);
51-
bool ECPGdo(int, int, int, const char *, char *,...);
51+
bool ECPGdo(int, int, int, const char *, const char *,...);
5252
bool ECPGtrans(int, const char *, const char *);
5353
bool ECPGdisconnect(int, const char *);
54-
bool ECPGprepare(int, char *, char *);
55-
bool ECPGdeallocate(int, int, char *);
56-
bool ECPGdeallocate_one(int, char *);
54+
bool ECPGprepare(int, const char *, const char *);
55+
bool ECPGdeallocate(int, int, const char *);
56+
bool ECPGdeallocate_one(int, const char *);
5757
bool ECPGdeallocate_all(int);
5858
char *ECPGprepared_statement(const char *);
5959

@@ -75,10 +75,10 @@ bool ECPGdeallocate_desc(int line, const char *name);
7575
bool ECPGallocate_desc(int line, const char *name);
7676
void ECPGraise(int line, int code, const char *sqlstate, const char *str);
7777
void ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat);
78-
bool ECPGget_desc_header(int, char *, int *);
79-
bool ECPGget_desc(int, char *, int,...);
80-
bool ECPGset_desc_header(int, char *, int);
81-
bool ECPGset_desc(int, char *, int,...);
78+
bool ECPGget_desc_header(int, const char *, int *);
79+
bool ECPGget_desc(int, const char *, int,...);
80+
bool ECPGset_desc_header(int, const char *, int);
81+
bool ECPGset_desc(int, const char *, int,...);
8282

8383
void ECPGset_noind_null(enum ECPGttype, void *);
8484
bool ECPGis_noind_null(enum ECPGttype, void *);

src/interfaces/ecpg/preproc/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1998-2005, PostgreSQL Global Development Group
66
#
7-
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.114 2005/03/14 17:27:50 momjian Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.115 2005/11/30 12:49:49 meskes Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -14,7 +14,7 @@ top_builddir = ../../../..
1414
include $(top_builddir)/src/Makefile.global
1515

1616
MAJOR_VERSION= 4
17-
MINOR_VERSION= 1
17+
MINOR_VERSION= 2
1818
PATCHLEVEL=1
1919

2020
override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) \

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