Skip to content

Commit 0754b39

Browse files
author
Michael Meskes
committed
Removed some unneeded variables and comparisons
1 parent 7340793 commit 0754b39

File tree

15 files changed

+52
-50
lines changed

15 files changed

+52
-50
lines changed

src/interfaces/ecpg/ecpglib/execute.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.82 2009/02/03 08:55:45 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.83 2009/05/20 16:13:18 meskes Exp $ */
22

33
/*
44
* The aim is to get a simpler inteface to the database routines.
@@ -1501,7 +1501,7 @@ ECPGdo(const int lineno, const int compat, const int force_indicator, const char
15011501
*/
15021502
if (statement_type == ECPGst_prepnormal)
15031503
{
1504-
if (!ecpg_auto_prepare(lineno, connection_name, compat, questionmarks, &prepname, query))
1504+
if (!ecpg_auto_prepare(lineno, connection_name, compat, &prepname, query))
15051505
return (false);
15061506

15071507
/*
@@ -1519,7 +1519,7 @@ ECPGdo(const int lineno, const int compat, const int force_indicator, const char
15191519
if (statement_type == ECPGst_execute)
15201520
{
15211521
/* if we have an EXECUTE command, only the name is send */
1522-
char *command = ecpg_prepared(stmt->command, con, lineno);
1522+
char *command = ecpg_prepared(stmt->command, con);
15231523

15241524
if (command)
15251525
{

src/interfaces/ecpg/ecpglib/extern.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.34 2008/02/07 11:09:12 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.35 2009/05/20 16:13:18 meskes Exp $ */
22

33
#ifndef _ECPG_LIB_EXTERN_H
44
#define _ECPG_LIB_EXTERN_H
@@ -143,10 +143,10 @@ bool ecpg_store_input(const int, const bool, const struct variable *, char **,
143143
bool ecpg_check_PQresult(PGresult *, int, PGconn *, enum COMPAT_MODE);
144144
void ecpg_raise(int line, int code, const char *sqlstate, const char *str);
145145
void ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat);
146-
char *ecpg_prepared(const char *, struct connection *, int);
146+
char *ecpg_prepared(const char *, struct connection *);
147147
bool ecpg_deallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection * conn);
148148
void ecpg_log(const char *format,...);
149-
bool ecpg_auto_prepare(int, const char *, int, const int, char **, const char *);
149+
bool ecpg_auto_prepare(int, const char *, const int, char **, const char *);
150150
void ecpg_init_sqlca(struct sqlca_t * sqlca);
151151

152152
/* SQLSTATE values generated or processed by ecpglib (intentionally

src/interfaces/ecpg/ecpglib/prepare.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.29 2008/05/16 15:20:03 petere Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.30 2009/05/20 16:13:18 meskes Exp $ */
22

33
#define POSTGRES_ECPG_INTERNAL
44
#include "postgres_fe.h"
@@ -56,7 +56,7 @@ isvarchar(unsigned char c)
5656
}
5757

5858
static bool
59-
replace_variables(char **text, int lineno, bool questionmarks)
59+
replace_variables(char **text, int lineno)
6060
{
6161
bool string = false;
6262
int counter = 1,
@@ -110,8 +110,9 @@ replace_variables(char **text, int lineno, bool questionmarks)
110110
}
111111

112112
/* handle the EXEC SQL PREPARE statement */
113+
/* questionmarks is not needed but remians in there for the time being to not change the API */
113114
bool
114-
ECPGprepare(int lineno, const char *connection_name, const int questionmarks, const char *name, const char *variable)
115+
ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, const char *name, const char *variable)
115116
{
116117
struct connection *con;
117118
struct statement *stmt;
@@ -148,7 +149,7 @@ ECPGprepare(int lineno, const char *connection_name, const int questionmarks, co
148149
stmt->inlist = stmt->outlist = NULL;
149150

150151
/* if we have C variables in our statment replace them with '?' */
151-
replace_variables(&(stmt->command), lineno, questionmarks);
152+
replace_variables(&(stmt->command), lineno);
152153

153154
/* add prepared statement to our list */
154155
this->name = (char *) name;
@@ -290,7 +291,7 @@ ECPGdeallocate_all(int lineno, int compat, const char *connection_name)
290291
}
291292

292293
char *
293-
ecpg_prepared(const char *name, struct connection * con, int lineno)
294+
ecpg_prepared(const char *name, struct connection * con)
294295
{
295296
struct prepared_statement *this;
296297

@@ -299,10 +300,11 @@ ecpg_prepared(const char *name, struct connection * con, int lineno)
299300
}
300301

301302
/* return the prepared statement */
303+
/* lineno is not used here, but kept in to not break API */
302304
char *
303305
ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
304306
{
305-
return ecpg_prepared(name, ecpg_get_connection(connection_name), lineno);
307+
return ecpg_prepared(name, ecpg_get_connection(connection_name));
306308
}
307309

308310
/*
@@ -460,7 +462,7 @@ AddStmtToCache(int lineno, /* line # of statement */
460462

461463
/* handle cache and preparation of statments in auto-prepare mode */
462464
bool
463-
ecpg_auto_prepare(int lineno, const char *connection_name, int compat, const int questionmarks, char **name, const char *query)
465+
ecpg_auto_prepare(int lineno, const char *connection_name, int compat, char **name, const char *query)
464466
{
465467
int entNo;
466468

@@ -481,7 +483,7 @@ ecpg_auto_prepare(int lineno, const char *connection_name, int compat, const int
481483
*name = (char *) ecpg_alloc(STMTID_SIZE, lineno);
482484
sprintf(*name, "ecpg%d", nextStmtID++);
483485

484-
if (!ECPGprepare(lineno, connection_name, questionmarks, ecpg_strdup(*name, lineno), query))
486+
if (!ECPGprepare(lineno, connection_name, 0, ecpg_strdup(*name, lineno), query))
485487
return (false);
486488
if (AddStmtToCache(lineno, *name, connection_name, compat, query) < 0)
487489
return (false);

src/interfaces/ecpg/include/ecpglib.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* this is a small part of c.h since we don't want to leak all postgres
33
* definitions into ecpg programs
4-
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.77 2008/05/16 15:20:04 petere Exp $
4+
* $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.78 2009/05/20 16:13:18 meskes Exp $
55
*/
66

77
#ifndef _ECPGLIB_H
@@ -54,7 +54,7 @@ bool ECPGconnect(int, int, const char *, const char *, const char *, const char
5454
bool ECPGdo(const int, const int, const int, const char *, const bool, const int, const char *,...);
5555
bool ECPGtrans(int, const char *, const char *);
5656
bool ECPGdisconnect(int, const char *);
57-
bool ECPGprepare(int, const char *, const int, const char *, const char *);
57+
bool ECPGprepare(int, const char *, const bool, const char *, const char *);
5858
bool ECPGdeallocate(int, int, const char *, const char *);
5959
bool ECPGdeallocate_all(int, int, const char *);
6060
char *ECPGprepared_statement(const char *, const char *, int);

src/interfaces/ecpg/pgtypeslib/datetime.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.35 2009/02/04 08:51:09 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.36 2009/05/20 16:13:18 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

@@ -74,7 +74,7 @@ PGTYPESdate_from_asc(char *str, char **endptr)
7474
return INT_MIN;
7575
}
7676

77-
if (ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf, ptr) != 0 ||
77+
if (ParseDateTime(str, lowstr, field, ftype, &nf, ptr) != 0 ||
7878
DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, EuroDates) != 0)
7979
{
8080
errno = PGTYPES_DATE_BAD_DATE;

src/interfaces/ecpg/pgtypeslib/dt.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt.h,v 1.41 2009/02/04 08:51:09 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt.h,v 1.42 2009/05/20 16:13:18 meskes Exp $ */
22

33
#ifndef DT_H
44
#define DT_H
@@ -334,7 +334,7 @@ do { \
334334

335335
int DecodeTimeOnly(char **, int *, int, int *, struct tm *, fsec_t *, int *);
336336
int DecodeInterval(char **, int *, int, int *, struct tm *, fsec_t *);
337-
int DecodeTime(char *, int, int *, struct tm *, fsec_t *);
337+
int DecodeTime(char *, int *, struct tm *, fsec_t *);
338338
int EncodeTimeOnly(struct tm *, fsec_t, int *, int, char *);
339339
int EncodeDateTime(struct tm *, fsec_t, int *, char **, int, char *, bool);
340340
int EncodeInterval(struct tm *, fsec_t, int, char *);
@@ -343,7 +343,7 @@ int DecodeUnits(int field, char *lowtoken, int *val);
343343
bool CheckDateTokenTables(void);
344344
int EncodeDateOnly(struct tm *, int, char *, bool);
345345
int GetEpochTime(struct tm *);
346-
int ParseDateTime(char *, char *, char **, int *, int, int *, char **);
346+
int ParseDateTime(char *, char *, char **, int *, int *, char **);
347347
int DecodeDateTime(char **, int *, int, int *, struct tm *, fsec_t *, bool);
348348
void j2date(int, int *, int *, int *);
349349
void GetCurrentDateTime(struct tm *);

src/interfaces/ecpg/pgtypeslib/dt_common.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.48 2009/03/22 01:12:32 tgl Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.49 2009/05/20 16:13:18 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

@@ -1132,7 +1132,7 @@ dt2time(double jd, int *hour, int *min, int *sec, fsec_t *fsec)
11321132
*/
11331133
static int
11341134
DecodeNumberField(int len, char *str, int fmask,
1135-
int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits, bool EuroDates)
1135+
int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits)
11361136
{
11371137
char *cp;
11381138

@@ -1258,7 +1258,7 @@ DecodeNumber(int flen, char *str, int fmask,
12581258
*/
12591259
if (cp - str > 2)
12601260
return DecodeNumberField(flen, str, (fmask | DTK_DATE_M),
1261-
tmask, tm, fsec, is2digits, EuroDates);
1261+
tmask, tm, fsec, is2digits);
12621262

12631263
*fsec = strtod(cp, &cp);
12641264
if (*cp != '\0')
@@ -1476,7 +1476,7 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm * tm, bool EuroDates)
14761476
* can be used to represent time spans.
14771477
*/
14781478
int
1479-
DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec)
1479+
DecodeTime(char *str, int *tmask, struct tm * tm, fsec_t *fsec)
14801480
{
14811481
char *cp;
14821482

@@ -1640,7 +1640,7 @@ DecodePosixTimezone(char *str, int *tzp)
16401640
*/
16411641
int
16421642
ParseDateTime(char *timestr, char *lowstr,
1643-
char **field, int *ftype, int maxfields, int *numfields, char **endstr)
1643+
char **field, int *ftype, int *numfields, char **endstr)
16441644
{
16451645
int nf = 0;
16461646
char *lp = lowstr;
@@ -1928,7 +1928,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
19281928
* time
19291929
*/
19301930
if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], fmask,
1931-
&tmask, tm, fsec, &is2digits, EuroDates)) < 0)
1931+
&tmask, tm, fsec, &is2digits)) < 0)
19321932
return -1;
19331933

19341934
/*
@@ -1951,7 +1951,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
19511951
break;
19521952

19531953
case DTK_TIME:
1954-
if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0)
1954+
if (DecodeTime(field[i], &tmask, tm, fsec) != 0)
19551955
return -1;
19561956

19571957
/*
@@ -2116,7 +2116,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
21162116
case DTK_TIME:
21172117
/* previous field was "t" for ISO time */
21182118
if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], (fmask | DTK_DATE_M),
2119-
&tmask, tm, fsec, &is2digits, EuroDates)) < 0)
2119+
&tmask, tm, fsec, &is2digits)) < 0)
21202120
return -1;
21212121

21222122
if (tmask != DTK_TIME_M)
@@ -2154,13 +2154,13 @@ DecodeDateTime(char **field, int *ftype, int nf,
21542154
* Example: 20011223 or 040506
21552155
*/
21562156
if ((ftype[i] = DecodeNumberField(flen, field[i], fmask,
2157-
&tmask, tm, fsec, &is2digits, EuroDates)) < 0)
2157+
&tmask, tm, fsec, &is2digits)) < 0)
21582158
return -1;
21592159
}
21602160
else if (flen > 4)
21612161
{
21622162
if ((ftype[i] = DecodeNumberField(flen, field[i], fmask,
2163-
&tmask, tm, fsec, &is2digits, EuroDates)) < 0)
2163+
&tmask, tm, fsec, &is2digits)) < 0)
21642164
return -1;
21652165
}
21662166
/* otherwise it is a single date/time field... */
@@ -2580,10 +2580,10 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp * d,
25802580
int scan_type;
25812581

25822582
char *pstr,
2583-
*pfmt,
2584-
*tmp;
2585-
int err = 1;
2586-
int j;
2583+
*pfmt,
2584+
*tmp;
2585+
int err = 1;
2586+
int j;
25872587
struct tm tm;
25882588

25892589
pfmt = fmt;
@@ -2908,7 +2908,7 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp * d,
29082908
pfmt++;
29092909
scan_type = PGTYPES_TYPE_UINT;
29102910
err = pgtypes_defmt_scan(&scan_val, scan_type, &pstr, pfmt);
2911-
if (scan_val.uint_val < 0 || scan_val.uint_val > 53)
2911+
if (scan_val.uint_val > 53)
29122912
err = 1;
29132913
break;
29142914
case 'V':
@@ -2922,14 +2922,14 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp * d,
29222922
pfmt++;
29232923
scan_type = PGTYPES_TYPE_UINT;
29242924
err = pgtypes_defmt_scan(&scan_val, scan_type, &pstr, pfmt);
2925-
if (scan_val.uint_val < 0 || scan_val.uint_val > 6)
2925+
if (scan_val.uint_val > 6)
29262926
err = 1;
29272927
break;
29282928
case 'W':
29292929
pfmt++;
29302930
scan_type = PGTYPES_TYPE_UINT;
29312931
err = pgtypes_defmt_scan(&scan_val, scan_type, &pstr, pfmt);
2932-
if (scan_val.uint_val < 0 || scan_val.uint_val > 53)
2932+
if (scan_val.uint_val > 53)
29332933
err = 1;
29342934
break;
29352935
case 'x':

src/interfaces/ecpg/pgtypeslib/interval.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/pgtypeslib/interval.c,v 1.39 2008/11/26 16:47:08 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.40 2009/05/20 16:13:18 meskes Exp $ */
22

33
#include "postgres_fe.h"
44
#include <time.h>
@@ -362,7 +362,7 @@ DecodeInterval(char **field, int *ftype, int nf, /*int range,*/
362362
switch (ftype[i])
363363
{
364364
case DTK_TIME:
365-
dterr = DecodeTime(field[i], fmask, /* range, */
365+
dterr = DecodeTime(field[i], /* range, */
366366
&tmask, tm, fsec);
367367
if (dterr)
368368
return dterr;
@@ -384,7 +384,7 @@ DecodeInterval(char **field, int *ftype, int nf, /*int range,*/
384384
* and signed year-month values.
385385
*/
386386
if (strchr(field[i] + 1, ':') != NULL &&
387-
DecodeTime(field[i] + 1, fmask, /* INTERVAL_FULL_RANGE, */
387+
DecodeTime(field[i] + 1, /* INTERVAL_FULL_RANGE, */
388388
&tmask, tm, fsec) == 0)
389389
{
390390
if (*field[i] == '-')
@@ -1096,7 +1096,7 @@ PGTYPESinterval_from_asc(char *str, char **endptr)
10961096
return NULL;
10971097
}
10981098

1099-
if (ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf, ptr) != 0 ||
1099+
if (ParseDateTime(str, lowstr, field, ftype, &nf, ptr) != 0 ||
11001100
(DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 0 &&
11011101
DecodeISO8601Interval(str, &dtype, tm, &fsec) != 0))
11021102
{

src/interfaces/ecpg/pgtypeslib/timestamp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/timestamp.c,v 1.43 2009/02/04 08:51:10 meskes Exp $
2+
* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/timestamp.c,v 1.44 2009/05/20 16:13:18 meskes Exp $
33
*/
44
#include "postgres_fe.h"
55

@@ -302,7 +302,7 @@ PGTYPEStimestamp_from_asc(char *str, char **endptr)
302302
return (noresult);
303303
}
304304

305-
if (ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf, ptr) != 0 ||
305+
if (ParseDateTime(str, lowstr, field, ftype, &nf, ptr) != 0 ||
306306
DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, 0) != 0)
307307
{
308308
errno = PGTYPES_TS_BAD_TIMESTAMP;

src/interfaces/ecpg/test/expected/sql-code100.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void);
9292

9393

9494

95-
int main(int argc, char **argv)
95+
int main()
9696
{ /* exec sql begin declare section */
9797

9898

src/interfaces/ecpg/test/expected/thread-alloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
185185
return 0;
186186
}
187187

188-
int main (int argc, char** argv)
188+
int main ()
189189
{
190190
int i;
191191
#ifdef WIN32

src/interfaces/ecpg/test/expected/thread-descriptor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ if (sqlca.sqlcode < 0) sqlprint();
126126
return 0;
127127
}
128128

129-
int main (int argc, char** argv)
129+
int main ()
130130
{
131131
#ifdef ENABLE_THREAD_SAFETY
132132
int i;

src/interfaces/ecpg/test/sql/code100.pgc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exec sql include sqlca;
44
exec sql include ../regression;
55

66

7-
int main(int argc, char **argv)
7+
int main()
88
{ exec sql begin declare section;
99
int index;
1010
exec sql end declare section;

src/interfaces/ecpg/test/thread/alloc.pgc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void* fn(void* arg)
5757
return 0;
5858
}
5959

60-
int main (int argc, char** argv)
60+
int main ()
6161
{
6262
int i;
6363
#ifdef WIN32

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