]> granicus.if.org Git - postgresql/commitdiff
Removed some unneeded variables and comparisons
authorMichael Meskes <meskes@postgresql.org>
Wed, 20 May 2009 16:13:18 +0000 (16:13 +0000)
committerMichael Meskes <meskes@postgresql.org>
Wed, 20 May 2009 16:13:18 +0000 (16:13 +0000)
15 files changed:
src/interfaces/ecpg/ecpglib/execute.c
src/interfaces/ecpg/ecpglib/extern.h
src/interfaces/ecpg/ecpglib/prepare.c
src/interfaces/ecpg/include/ecpglib.h
src/interfaces/ecpg/pgtypeslib/datetime.c
src/interfaces/ecpg/pgtypeslib/dt.h
src/interfaces/ecpg/pgtypeslib/dt_common.c
src/interfaces/ecpg/pgtypeslib/interval.c
src/interfaces/ecpg/pgtypeslib/timestamp.c
src/interfaces/ecpg/test/expected/sql-code100.c
src/interfaces/ecpg/test/expected/thread-alloc.c
src/interfaces/ecpg/test/expected/thread-descriptor.c
src/interfaces/ecpg/test/sql/code100.pgc
src/interfaces/ecpg/test/thread/alloc.pgc
src/interfaces/ecpg/test/thread/descriptor.pgc

index 97524f82d1c11082e059385143c8b2e9427c5424..9363b5668fb1ae53bd458c27639867efa21eeaba 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.82 2009/02/03 08:55:45 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.83 2009/05/20 16:13:18 meskes Exp $ */
 
 /*
  * 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
         */
        if (statement_type == ECPGst_prepnormal)
        {
-               if (!ecpg_auto_prepare(lineno, connection_name, compat, questionmarks, &prepname, query))
+               if (!ecpg_auto_prepare(lineno, connection_name, compat, &prepname, query))
                        return (false);
 
                /*
@@ -1519,7 +1519,7 @@ ECPGdo(const int lineno, const int compat, const int force_indicator, const char
        if (statement_type == ECPGst_execute)
        {
                /* if we have an EXECUTE command, only the name is send */
-               char       *command = ecpg_prepared(stmt->command, con, lineno);
+               char       *command = ecpg_prepared(stmt->command, con);
 
                if (command)
                {
index 41098903ec8f2147d3925283419077b5832ef102..dab33e337b8f89e22388cc3278809ffd6f8a0fbb 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.34 2008/02/07 11:09:12 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/extern.h,v 1.35 2009/05/20 16:13:18 meskes Exp $ */
 
 #ifndef _ECPG_LIB_EXTERN_H
 #define _ECPG_LIB_EXTERN_H
@@ -143,10 +143,10 @@ bool              ecpg_store_input(const int, const bool, const struct variable *, char **,
 bool           ecpg_check_PQresult(PGresult *, int, PGconn *, enum COMPAT_MODE);
 void           ecpg_raise(int line, int code, const char *sqlstate, const char *str);
 void           ecpg_raise_backend(int line, PGresult *result, PGconn *conn, int compat);
-char      *ecpg_prepared(const char *, struct connection *, int);
+char      *ecpg_prepared(const char *, struct connection *);
 bool           ecpg_deallocate_all_conn(int lineno, enum COMPAT_MODE c, struct connection * conn);
 void           ecpg_log(const char *format,...);
-bool           ecpg_auto_prepare(int, const char *, int, const int, char **, const char *);
+bool           ecpg_auto_prepare(int, const char *, const int, char **, const char *);
 void           ecpg_init_sqlca(struct sqlca_t * sqlca);
 
 /* SQLSTATE values generated or processed by ecpglib (intentionally
index f6a88d877a1f55798e2c591241a6021f87ba1e9d..637d77b2069eb44156b95b918b4f77cca752f219 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.29 2008/05/16 15:20:03 petere Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.30 2009/05/20 16:13:18 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -56,7 +56,7 @@ isvarchar(unsigned char c)
 }
 
 static bool
-replace_variables(char **text, int lineno, bool questionmarks)
+replace_variables(char **text, int lineno)
 {
        bool            string = false;
        int                     counter = 1,
@@ -110,8 +110,9 @@ replace_variables(char **text, int lineno, bool questionmarks)
 }
 
 /* handle the EXEC SQL PREPARE statement */
+/* questionmarks is not needed but remians in there for the time being to not change the API */
 bool
-ECPGprepare(int lineno, const char *connection_name, const int questionmarks, const char *name, const char *variable)
+ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, const char *name, const char *variable)
 {
        struct connection *con;
        struct statement *stmt;
@@ -148,7 +149,7 @@ ECPGprepare(int lineno, const char *connection_name, const int questionmarks, co
        stmt->inlist = stmt->outlist = NULL;
 
        /* if we have C variables in our statment replace them with '?' */
-       replace_variables(&(stmt->command), lineno, questionmarks);
+       replace_variables(&(stmt->command), lineno);
 
        /* add prepared statement to our list */
        this->name = (char *) name;
@@ -290,7 +291,7 @@ ECPGdeallocate_all(int lineno, int compat, const char *connection_name)
 }
 
 char *
-ecpg_prepared(const char *name, struct connection * con, int lineno)
+ecpg_prepared(const char *name, struct connection * con)
 {
        struct prepared_statement *this;
 
@@ -299,10 +300,11 @@ ecpg_prepared(const char *name, struct connection * con, int lineno)
 }
 
 /* return the prepared statement */
+/* lineno is not used here, but kept in to not break API */
 char *
 ECPGprepared_statement(const char *connection_name, const char *name, int lineno)
 {
-       return ecpg_prepared(name, ecpg_get_connection(connection_name), lineno);
+       return ecpg_prepared(name, ecpg_get_connection(connection_name));
 }
 
 /*
@@ -460,7 +462,7 @@ AddStmtToCache(int lineno,          /* line # of statement          */
 
 /* handle cache and preparation of statments in auto-prepare mode */
 bool
-ecpg_auto_prepare(int lineno, const char *connection_name, int compat, const int questionmarks, char **name, const char *query)
+ecpg_auto_prepare(int lineno, const char *connection_name, int compat, char **name, const char *query)
 {
        int                     entNo;
 
@@ -481,7 +483,7 @@ ecpg_auto_prepare(int lineno, const char *connection_name, int compat, const int
                *name = (char *) ecpg_alloc(STMTID_SIZE, lineno);
                sprintf(*name, "ecpg%d", nextStmtID++);
 
-               if (!ECPGprepare(lineno, connection_name, questionmarks, ecpg_strdup(*name, lineno), query))
+               if (!ECPGprepare(lineno, connection_name, 0, ecpg_strdup(*name, lineno), query))
                        return (false);
                if (AddStmtToCache(lineno, *name, connection_name, compat, query) < 0)
                        return (false);
index 8c682e5782c0db09e0624419b76183ec61f4042a..5830df8bdcb8090458b4da088d530f606da5379c 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * this is a small part of c.h since we don't want to leak all postgres
  * definitions into ecpg programs
- * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.77 2008/05/16 15:20:04 petere Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/include/ecpglib.h,v 1.78 2009/05/20 16:13:18 meskes Exp $
  */
 
 #ifndef _ECPGLIB_H
@@ -54,7 +54,7 @@ bool          ECPGconnect(int, int, const char *, const char *, const char *, const char
 bool           ECPGdo(const int, const int, const int, const char *, const bool, const int, const char *,...);
 bool           ECPGtrans(int, const char *, const char *);
 bool           ECPGdisconnect(int, const char *);
-bool           ECPGprepare(int, const char *, const int, const char *, const char *);
+bool           ECPGprepare(int, const char *, const bool, const char *, const char *);
 bool           ECPGdeallocate(int, int, const char *, const char *);
 bool           ECPGdeallocate_all(int, int, const char *);
 char           *ECPGprepared_statement(const char *, const char *, int);
index 9dc900e9b25729f4caad3acbefdbf612132b1b8c..eae776bf2353e631dc596f526a267bee6238ff13 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.35 2009/02/04 08:51:09 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.36 2009/05/20 16:13:18 meskes Exp $ */
 
 #include "postgres_fe.h"
 
@@ -74,7 +74,7 @@ PGTYPESdate_from_asc(char *str, char **endptr)
                return INT_MIN;
        }
 
-       if (ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf, ptr) != 0 ||
+       if (ParseDateTime(str, lowstr, field, ftype, &nf, ptr) != 0 ||
                DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, EuroDates) != 0)
        {
                errno = PGTYPES_DATE_BAD_DATE;
index ac0b1369029b15acc40281c750efdc3bfdfaf9b3..1da5b8cc529f999bf5edeeeac40e94fed842bdce 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt.h,v 1.41 2009/02/04 08:51:09 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt.h,v 1.42 2009/05/20 16:13:18 meskes Exp $ */
 
 #ifndef DT_H
 #define DT_H
@@ -334,7 +334,7 @@ do { \
 
 int                    DecodeTimeOnly(char **, int *, int, int *, struct tm *, fsec_t *, int *);
 int                    DecodeInterval(char **, int *, int, int *, struct tm *, fsec_t *);
-int                    DecodeTime(char *, int, int *, struct tm *, fsec_t *);
+int                    DecodeTime(char *, int *, struct tm *, fsec_t *);
 int                    EncodeTimeOnly(struct tm *, fsec_t, int *, int, char *);
 int                    EncodeDateTime(struct tm *, fsec_t, int *, char **, int, char *, bool);
 int                    EncodeInterval(struct tm *, fsec_t, int, char *);
@@ -343,7 +343,7 @@ int                 DecodeUnits(int field, char *lowtoken, int *val);
 bool           CheckDateTokenTables(void);
 int                    EncodeDateOnly(struct tm *, int, char *, bool);
 int            GetEpochTime(struct tm *);
-int                    ParseDateTime(char *, char *, char **, int *, int, int *, char **);
+int                    ParseDateTime(char *, char *, char **, int *, int *, char **);
 int                    DecodeDateTime(char **, int *, int, int *, struct tm *, fsec_t *, bool);
 void           j2date(int, int *, int *, int *);
 void           GetCurrentDateTime(struct tm *);
index a778960bc4debd758d2c7d4c23ec6d1a085d6223..20e0a9d31152866e43b16a1efd88b54ea8d9c9e1 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.48 2009/03/22 01:12:32 tgl Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.49 2009/05/20 16:13:18 meskes Exp $ */
 
 #include "postgres_fe.h"
 
@@ -1132,7 +1132,7 @@ dt2time(double jd, int *hour, int *min, int *sec, fsec_t *fsec)
  */
 static int
 DecodeNumberField(int len, char *str, int fmask,
-       int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits, bool EuroDates)
+       int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits)
 {
        char       *cp;
 
@@ -1258,7 +1258,7 @@ DecodeNumber(int flen, char *str, int fmask,
                 */
                if (cp - str > 2)
                        return DecodeNumberField(flen, str, (fmask | DTK_DATE_M),
-                                                                        tmask, tm, fsec, is2digits, EuroDates);
+                                                                        tmask, tm, fsec, is2digits);
 
                *fsec = strtod(cp, &cp);
                if (*cp != '\0')
@@ -1476,7 +1476,7 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm * tm, bool EuroDates)
  *     can be used to represent time spans.
  */
 int
-DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec)
+DecodeTime(char *str, int *tmask, struct tm * tm, fsec_t *fsec)
 {
        char       *cp;
 
@@ -1640,7 +1640,7 @@ DecodePosixTimezone(char *str, int *tzp)
  */
 int
 ParseDateTime(char *timestr, char *lowstr,
-         char **field, int *ftype, int maxfields, int *numfields, char **endstr)
+         char **field, int *ftype, int *numfields, char **endstr)
 {
        int                     nf = 0;
        char       *lp = lowstr;
@@ -1928,7 +1928,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
                                                 * time
                                                 */
                                                if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], fmask,
-                                                          &tmask, tm, fsec, &is2digits, EuroDates)) < 0)
+                                                          &tmask, tm, fsec, &is2digits)) < 0)
                                                        return -1;
 
                                                /*
@@ -1951,7 +1951,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
                                break;
 
                        case DTK_TIME:
-                               if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0)
+                               if (DecodeTime(field[i], &tmask, tm, fsec) != 0)
                                        return -1;
 
                                /*
@@ -2116,7 +2116,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
                                                case DTK_TIME:
                                                        /* previous field was "t" for ISO time */
                                                        if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], (fmask | DTK_DATE_M),
-                                                          &tmask, tm, fsec, &is2digits, EuroDates)) < 0)
+                                                          &tmask, tm, fsec, &is2digits)) < 0)
                                                                return -1;
 
                                                        if (tmask != DTK_TIME_M)
@@ -2154,13 +2154,13 @@ DecodeDateTime(char **field, int *ftype, int nf,
                                                 * Example: 20011223 or 040506
                                                 */
                                                if ((ftype[i] = DecodeNumberField(flen, field[i], fmask,
-                                                          &tmask, tm, fsec, &is2digits, EuroDates)) < 0)
+                                                          &tmask, tm, fsec, &is2digits)) < 0)
                                                        return -1;
                                        }
                                        else if (flen > 4)
                                        {
                                                if ((ftype[i] = DecodeNumberField(flen, field[i], fmask,
-                                                          &tmask, tm, fsec, &is2digits, EuroDates)) < 0)
+                                                          &tmask, tm, fsec, &is2digits)) < 0)
                                                        return -1;
                                        }
                                        /* otherwise it is a single date/time field... */
@@ -2580,10 +2580,10 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp * d,
        int                     scan_type;
 
        char       *pstr,
-                          *pfmt,
-                          *tmp;
-       int                     err = 1;
-       int                     j;
+                       *pfmt,
+                       *tmp;
+       int             err = 1;
+       int     j;
        struct tm       tm;
 
        pfmt = fmt;
@@ -2908,7 +2908,7 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp * d,
                                pfmt++;
                                scan_type = PGTYPES_TYPE_UINT;
                                err = pgtypes_defmt_scan(&scan_val, scan_type, &pstr, pfmt);
-                               if (scan_val.uint_val < 0 || scan_val.uint_val > 53)
+                               if (scan_val.uint_val > 53)
                                        err = 1;
                                break;
                        case 'V':
@@ -2922,14 +2922,14 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp * d,
                                pfmt++;
                                scan_type = PGTYPES_TYPE_UINT;
                                err = pgtypes_defmt_scan(&scan_val, scan_type, &pstr, pfmt);
-                               if (scan_val.uint_val < 0 || scan_val.uint_val > 6)
+                               if (scan_val.uint_val > 6)
                                        err = 1;
                                break;
                        case 'W':
                                pfmt++;
                                scan_type = PGTYPES_TYPE_UINT;
                                err = pgtypes_defmt_scan(&scan_val, scan_type, &pstr, pfmt);
-                               if (scan_val.uint_val < 0 || scan_val.uint_val > 53)
+                               if (scan_val.uint_val > 53)
                                        err = 1;
                                break;
                        case 'x':
index 4b2c97f9d00bbe85e5e3d199e07d7b6296ecd73b..2ab84a38e0ce0fdcff3d493c05c08ddca3d64b7d 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.39 2008/11/26 16:47:08 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.40 2009/05/20 16:13:18 meskes Exp $ */
 
 #include "postgres_fe.h"
 #include <time.h>
@@ -362,7 +362,7 @@ DecodeInterval(char **field, int *ftype, int nf, /*int range,*/
                switch (ftype[i])
                {
                        case DTK_TIME:
-                               dterr = DecodeTime(field[i], fmask, /* range, */
+                               dterr = DecodeTime(field[i], /* range, */
                                                                   &tmask, tm, fsec);
                                if (dterr)
                                        return dterr;
@@ -384,7 +384,7 @@ DecodeInterval(char **field, int *ftype, int nf, /*int range,*/
                                 * and signed year-month values.
                                 */
                                if (strchr(field[i] + 1, ':') != NULL &&
-                                       DecodeTime(field[i] + 1, fmask, /* INTERVAL_FULL_RANGE, */
+                                       DecodeTime(field[i] + 1, /* INTERVAL_FULL_RANGE, */
                                                           &tmask, tm, fsec) == 0)
                                {
                                        if (*field[i] == '-')
@@ -1096,7 +1096,7 @@ PGTYPESinterval_from_asc(char *str, char **endptr)
                return NULL;
        }
 
-       if (ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf, ptr) != 0 ||
+       if (ParseDateTime(str, lowstr, field, ftype, &nf, ptr) != 0 ||
                (DecodeInterval(field, ftype, nf, &dtype, tm, &fsec) != 0 &&
                 DecodeISO8601Interval(str, &dtype, tm, &fsec) != 0))
        {
index e4ff8b664eccc7551aa576fa8f8d9c3c095b9e62..ff44a8575676f19cfcedd522e752133669c2ba3e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/timestamp.c,v 1.43 2009/02/04 08:51:10 meskes Exp $ 
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/timestamp.c,v 1.44 2009/05/20 16:13:18 meskes Exp $ 
  */
 #include "postgres_fe.h"
 
@@ -302,7 +302,7 @@ PGTYPEStimestamp_from_asc(char *str, char **endptr)
                return (noresult);
        }
 
-       if (ParseDateTime(str, lowstr, field, ftype, MAXDATEFIELDS, &nf, ptr) != 0 ||
+       if (ParseDateTime(str, lowstr, field, ftype, &nf, ptr) != 0 ||
                DecodeDateTime(field, ftype, nf, &dtype, tm, &fsec, 0) != 0)
        {
                errno = PGTYPES_TS_BAD_TIMESTAMP;
index 2fc320d5c007714bb49e369003bcf8f25f1bbdee..e250690e9c8c3476fffda8ea29bb8915888cc747 100644 (file)
@@ -92,7 +92,7 @@ struct sqlca_t *ECPGget_sqlca(void);
 
 
 
-int main(int argc, char **argv)
+int main()
 {  /* exec sql begin declare section */
     
    
index 2cb8bde4f41b204fa1511b940bdd8300b850f7e4..b99b868001270293b88b14d789032ef04315595c 100644 (file)
@@ -185,7 +185,7 @@ if (sqlca.sqlcode < 0) sqlprint();}
        return 0;
 }
 
-int main (int argc, char** argv)
+int main ()
 {
        int i;
 #ifdef WIN32
index d842e8a38b74e8143bedd58e279f96f124fb36a3..2584626f4fda280ec14cbb6ce62dbafd3fa5881a 100644 (file)
@@ -126,7 +126,7 @@ if (sqlca.sqlcode < 0) sqlprint();
        return 0;
 }
 
-int main (int argc, char** argv)
+int main ()
 {
 #ifdef ENABLE_THREAD_SAFETY
        int i;
index 69614534fe188d431409fab1f24bb47462517f00..2ae6d15eade99a53abdbf1bfb5d1902c61b45c06 100644 (file)
@@ -4,7 +4,7 @@ exec sql include sqlca;
 exec sql include ../regression;
 
 
-int main(int argc, char **argv)
+int main()
 {  exec sql begin declare section;
    int index;
    exec sql end declare section;
index 1b28d3a5b60c20ca203f718e9f08166c269766c6..220dc43fb8a179acc5ed9615afd132660fc7aeb7 100644 (file)
@@ -57,7 +57,7 @@ static void* fn(void* arg)
        return 0;
 }
 
-int main (int argc, char** argv)
+int main ()
 {
        int i;
 #ifdef WIN32
index 9560d105b6aa1d5be620bb9e6338c9b0d0096bb9..e07a5e22b7a393171fff928e12bf0196e40f5a0d 100644 (file)
@@ -33,7 +33,7 @@ static void* fn(void* arg)
        return 0;
 }
 
-int main (int argc, char** argv)
+int main ()
 {
 #ifdef ENABLE_THREAD_SAFETY
        int i;