- Made several variables "const char *" instead of "char *" as proposed by Qingqing...
authorMichael Meskes
Wed, 30 Nov 2005 12:49:49 +0000 (12:49 +0000)
committerMichael Meskes
Wed, 30 Nov 2005 12:49:49 +0000 (12:49 +0000)
- Replaced all strdup() calls by ECPGstrdup().
- Set ecpg library version to 5.2.
- Set ecpg version to 4.2.1.

src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ecpglib/Makefile
src/interfaces/ecpg/ecpglib/connect.c
src/interfaces/ecpg/ecpglib/descriptor.c
src/interfaces/ecpg/ecpglib/execute.c
src/interfaces/ecpg/ecpglib/prepare.c
src/interfaces/ecpg/include/ecpglib.h
src/interfaces/ecpg/preproc/Makefile

index 4ad3725af00a2acd37e9d7f65b71126076eecc89..6357bf98cb3906f4efb4d52dbe88c713c8519f1b 100644 (file)
@@ -1952,3 +1952,11 @@ Wed Oct  5 16:57:42 CEST 2005
    - Set ecpg library version to 5.1.
    - Set ecpg version to 4.1.1.
 
+Wed Nov 30 12:49:13 CET 2005
+
+   - Made several variables "const char *" instead of "char *" as
+     proposed by Qingqing Zhou .
+   - Replaced all strdup() calls by ECPGstrdup().
+   - Set ecpg library version to 5.2.
+   - Set ecpg version to 4.2.1.
+
index 0cc752d22e2410972a51f005c5ce9656a5a07012..deaf695d97b142d2e20157af3994857a2e0fb9b3 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.33 2005/03/14 17:27:50 momjian Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.34 2005/11/30 12:49:49 meskes Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global
 
 NAME= ecpg
 SO_MAJOR_VERSION= 5
-SO_MINOR_VERSION= 1
+SO_MINOR_VERSION= 2
 DLTYPE= library
 
 override CPPFLAGS := -DFRONTEND -I$(top_srcdir)/src/interfaces/ecpg/include \
index 94d2f42ec176fe49058d72858638f45d3543b950..b5e023dcadc5fa73852a9590ad196d7d54e3c8bc 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.26 2005/10/15 02:49:47 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/connect.c,v 1.27 2005/11/30 12:49:49 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -265,7 +265,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
    struct sqlca_t *sqlca = ECPGget_sqlca();
    enum COMPAT_MODE compat = c;
    struct connection *this;
-   char       *dbname = name ? strdup(name) : NULL,
+   char       *dbname = name ? ECPGstrdup(name, lineno) : NULL,
               *host = NULL,
               *tmp,
               *port = NULL,
@@ -287,7 +287,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
        if (envname)
        {
            ECPGfree(dbname);
-           dbname = strdup(envname);
+           dbname = ECPGstrdup(envname, lineno);
        }
 
    }
@@ -307,17 +307,17 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
            tmp = strrchr(dbname, ':');
            if (tmp != NULL)    /* port number given */
            {
-               port = strdup(tmp + 1);
+               port = ECPGstrdup(tmp + 1, lineno);
                *tmp = '\0';
            }
 
            tmp = strrchr(dbname, '@');
            if (tmp != NULL)    /* host name given */
            {
-               host = strdup(tmp + 1);
+               host = ECPGstrdup(tmp + 1, lineno);
                *tmp = '\0';
            }
-           realname = strdup(dbname);
+           realname = ECPGstrdup(dbname, lineno);
        }
        else if (strncmp(dbname, "tcp:", 4) == 0 || strncmp(dbname, "unix:", 5) == 0)
        {
@@ -345,14 +345,14 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
                tmp = strrchr(dbname + offset, '?');
                if (tmp != NULL)    /* options given */
                {
-                   options = strdup(tmp + 1);
+                   options = ECPGstrdup(tmp + 1, lineno);
                    *tmp = '\0';
                }
 
                tmp = last_dir_separator(dbname + offset);
                if (tmp != NULL)    /* database name given */
                {
-                   realname = strdup(tmp + 1);
+                   realname = ECPGstrdup(tmp + 1, lineno);
                    *tmp = '\0';
                }
 
@@ -365,7 +365,7 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
                    if ((tmp2 = strchr(tmp + 1, ':')) != NULL)
                    {
                        *tmp2 = '\0';
-                       host = strdup(tmp + 1);
+                       host = ECPGstrdup(tmp + 1, lineno);
                        if (strncmp(dbname, "unix:", 5) != 0)
                        {
                            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
                        }
                    }
                    else
-                       port = strdup(tmp + 1);
+                       port = ECPGstrdup(tmp + 1, lineno);
                }
 
                if (strncmp(dbname, "unix:", 5) == 0)
@@ -407,14 +407,14 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
                    }
                }
                else
-                   host = strdup(dbname + offset);
+                   host = ECPGstrdup(dbname + offset, lineno);
 
            }
            else
-               realname = strdup(dbname);
+               realname = ECPGstrdup(dbname, lineno);
        }
        else
-           realname = strdup(dbname);
+           realname = ECPGstrdup(dbname, lineno);
    }
    else
        realname = NULL;
index 08c8d3479ceb8465c6c65a139553d425cf5b925d..5985595c79335ced364b4ab1f05d3da3fefe7cad 100644 (file)
@@ -1,6 +1,6 @@
 /* dynamic SQL support routines
  *
- * $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.12 2004/08/29 05:06:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/descriptor.c,v 1.13 2005/11/30 12:49:49 meskes Exp $
  */
 
 #define POSTGRES_ECPG_INTERNAL
@@ -49,7 +49,7 @@ ECPGDynamicType_DDT(Oid type)
 }
 
 bool
-ECPGget_desc_header(int lineno, char *desc_name, int *count)
+ECPGget_desc_header(int lineno, const char *desc_name, int *count)
 {
    PGresult   *ECPGresult;
    struct sqlca_t *sqlca = ECPGget_sqlca();
@@ -188,7 +188,7 @@ get_char_item(int lineno, void *var, enum ECPGttype vartype, char *value, int va
 }
 
 bool
-ECPGget_desc(int lineno, char *desc_name, int index,...)
+ECPGget_desc(int lineno, const char *desc_name, int index,...)
 {
    va_list     args;
    PGresult   *ECPGresult;
@@ -383,7 +383,7 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
 
        /* Make sure we do NOT honor the locale for numeric input */
        /* since the database gives the standard decimal point */
-       oldlocale = strdup(setlocale(LC_NUMERIC, NULL));
+       oldlocale = ECPGstrdup(setlocale(LC_NUMERIC, NULL), lineno);
        setlocale(LC_NUMERIC, "C");
 
        memset(&stmt, 0, sizeof stmt);
@@ -431,7 +431,7 @@ ECPGget_desc(int lineno, char *desc_name, int index,...)
 }
 
 bool
-ECPGset_desc_header(int lineno, char *desc_name, int count)
+ECPGset_desc_header(int lineno, const char *desc_name, int count)
 {
    struct descriptor *desc;
 
@@ -452,7 +452,7 @@ ECPGset_desc_header(int lineno, char *desc_name, int count)
 }
 
 bool
-ECPGset_desc(int lineno, char *desc_name, int index,...)
+ECPGset_desc(int lineno, const char *desc_name, int index,...)
 {
    va_list     args;
    struct descriptor *desc;
index ac870f0cc82b4ad14f5af10181a715e3613336e1..491d6e6040b8a13b0cb43174e83f799f80a2f61b 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.43 2005/10/15 02:49:47 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/execute.c,v 1.44 2005/11/30 12:49:49 meskes Exp $ */
 
 /*
  * The aim is to get a simpler inteface to the database routines.
@@ -141,7 +141,7 @@ ECPGget_variable(va_list APREF, enum ECPGttype type, struct variable * var, bool
  * ind_offset - indicator offset
  */
 static bool
-create_statement(int lineno, int compat, int force_indicator, struct connection * connection, struct statement ** stmt, char *query, va_list ap)
+create_statement(int lineno, int compat, int force_indicator, struct connection * connection, struct statement ** stmt, const char *query, va_list ap)
 {
    struct variable **list = &((*stmt)->inlist);
    enum ECPGttype type;
@@ -149,7 +149,7 @@ create_statement(int lineno, int compat, int force_indicator, struct connection
    if (!(*stmt = (struct statement *) ECPGalloc(sizeof(struct statement), lineno)))
        return false;
 
-   (*stmt)->command = query;
+   (*stmt)->command = ECPGstrdup(query, lineno);
    (*stmt)->connection = connection;
    (*stmt)->lineno = lineno;
    (*stmt)->compat = compat;
@@ -224,6 +224,7 @@ free_statement(struct statement * stmt)
        return;
    free_variable(stmt->inlist);
    free_variable(stmt->outlist);
+   ECPGfree(stmt->command);
    ECPGfree(stmt);
 }
 
@@ -1359,7 +1360,7 @@ ECPGexecute(struct statement * stmt)
 }
 
 bool
-ECPGdo(int lineno, int compat, int force_indicator, const char *connection_name, char *query,...)
+ECPGdo(int lineno, int compat, int force_indicator, const char *connection_name, const char *query,...)
 {
    va_list     args;
    struct statement *stmt;
@@ -1369,7 +1370,7 @@ ECPGdo(int lineno, int compat, int force_indicator, const char *connection_name,
 
    /* Make sure we do NOT honor the locale for numeric input/output */
    /* since the database wants the standard decimal point */
-   oldlocale = strdup(setlocale(LC_NUMERIC, NULL));
+   oldlocale = ECPGstrdup(setlocale(LC_NUMERIC, NULL), lineno);
    setlocale(LC_NUMERIC, "C");
 
    if (!ECPGinit(con, connection_name, lineno))
index cd57c41914fb9f9174ce593bb28371cfad249277..555c981c024784a360ac195d2ba1705718660297 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.14 2005/10/15 02:49:47 momjian Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v 1.15 2005/11/30 12:49:49 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -60,7 +60,7 @@ replace_variables(char *text)
 
 /* handle the EXEC SQL PREPARE statement */
 bool
-ECPGprepare(int lineno, char *name, char *variable)
+ECPGprepare(int lineno, const char *name, const char *variable)
 {
    struct statement *stmt;
    struct prepared_statement *this;
@@ -112,7 +112,7 @@ ECPGprepare(int lineno, char *name, char *variable)
 
 /* handle the EXEC SQL DEALLOCATE PREPARE statement */
 bool
-ECPGdeallocate(int lineno, int c, char *name)
+ECPGdeallocate(int lineno, int c, const char *name)
 {
    bool        ret = ECPGdeallocate_one(lineno, name);
    enum COMPAT_MODE compat = c;
@@ -133,7 +133,7 @@ ECPGdeallocate(int lineno, int c, char *name)
 }
 
 bool
-ECPGdeallocate_one(int lineno, char *name)
+ECPGdeallocate_one(int lineno, const char *name)
 {
    struct prepared_statement *this,
               *prev;
index 6145e79cb4df05910ed0cd711a3335ff85e5d83f..0bcaac1a86e96e8289675ff1c29b4a5fd3b13126 100644 (file)
@@ -48,12 +48,12 @@ bool        ECPGstatus(int, const char *);
 bool       ECPGsetcommit(int, const char *, const char *);
 bool       ECPGsetconn(int, const char *);
 bool       ECPGconnect(int, int, const char *, const char *, const char *, const char *, int);
-bool       ECPGdo(int, int, int, const char *, char *,...);
+bool       ECPGdo(int, int, int, const char *, const char *,...);
 bool       ECPGtrans(int, const char *, const char *);
 bool       ECPGdisconnect(int, const char *);
-bool       ECPGprepare(int, char *, char *);
-bool       ECPGdeallocate(int, int, char *);
-bool       ECPGdeallocate_one(int, char *);
+bool       ECPGprepare(int, const char *, const char *);
+bool       ECPGdeallocate(int, int, const char *);
+bool       ECPGdeallocate_one(int, const char *);
 bool       ECPGdeallocate_all(int);
 char      *ECPGprepared_statement(const char *);
 
@@ -75,10 +75,10 @@ bool        ECPGdeallocate_desc(int line, const char *name);
 bool       ECPGallocate_desc(int line, const char *name);
 void       ECPGraise(int line, int code, const char *sqlstate, const char *str);
 void       ECPGraise_backend(int line, PGresult *result, PGconn *conn, int compat);
-bool       ECPGget_desc_header(int, char *, int *);
-bool       ECPGget_desc(int, char *, int,...);
-bool       ECPGset_desc_header(int, char *, int);
-bool       ECPGset_desc(int, char *, int,...);
+bool       ECPGget_desc_header(int, const char *, int *);
+bool       ECPGget_desc(int, const char *, int,...);
+bool       ECPGset_desc_header(int, const char *, int);
+bool       ECPGset_desc(int, const char *, int,...);
 
 void       ECPGset_noind_null(enum ECPGttype, void *);
 bool       ECPGis_noind_null(enum ECPGttype, void *);
index b96fa1d3f855300361e71d815a199b33979ab0b1..3c39d5e00f6f08d23b5f2aa05313ae0a0508b94a 100644 (file)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1998-2005, PostgreSQL Global Development Group
 #
-# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.114 2005/03/14 17:27:50 momjian Exp $
+# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.115 2005/11/30 12:49:49 meskes Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -14,7 +14,7 @@ top_builddir = ../../../..
 include $(top_builddir)/src/Makefile.global
 
 MAJOR_VERSION= 4
-MINOR_VERSION= 1
+MINOR_VERSION= 2
 PATCHLEVEL=1
 
 override CPPFLAGS := -I$(srcdir)/../include -I$(srcdir) $(CPPFLAGS) \