Rename snprintf_add() snprintfcat().
authorHiroshi Inoue <h-inoue@dream.email.ne.jp>
Wed, 7 Jun 2017 09:26:17 +0000 (18:26 +0900)
committerHiroshi Inoue <h-inoue@dream.email.ne.jp>
Fri, 9 Jun 2017 03:04:26 +0000 (12:04 +0900)
Use SPRINTF_FIXED() or SPRINTFCAT_FIXED() where they are available.

18 files changed:
connection.c
convert.c
dlg_specific.c
execute.c
info.c
loadlib.c
misc.c
misc.h
mylog.c
odbcapi.c
odbcapi30w.c
parse.c
pgapi30.c
psqlsetup.c
qresult.c
results.c
setup.c
statement.c

index 1df68d782bcce15337cefe1968d460b182bb2417..212bf4fe44eb8622e036efc6f5e5a8f3620f5143 100644 (file)
@@ -630,7 +630,7 @@ CC_send_client_encoding(ConnectionClass *self, const char * encoding)
        int errnum = CC_get_errornumber(self);
        BOOL    cmd_success;
 
-       snprintf(query, sizeof(query), "set client_encoding to '%s'", encoding);
+       SPRINTF_FIXED(query, "set client_encoding to '%s'", encoding);
        res = CC_send_query(self, query, NULL, IGNORE_ABORT_ON_CONN | ROLLBACK_ON_ERROR, NULL);
        cmd_success = QR_command_maybe_successful(res);
        QR_Destructor(res);
@@ -1428,7 +1428,7 @@ static void CC_clear_cursors(ConnectionClass *self, BOOL on_abort)
 
                if (QR_needs_survival_check(res))
                {
-                   snprintf(cmd, sizeof(cmd), "MOVE 0 in \"%s\"", QR_get_cursor(res));
+                   SPRINTF_FIXED(cmd, "MOVE 0 in \"%s\"", QR_get_cursor(res));
                    CONNLOCK_RELEASE(self);
                    wres = CC_send_query(self, cmd, NULL, ROLLBACK_ON_ERROR | IGNORE_ABORT_ON_CONN, NULL);
                    QR_set_no_survival_check(res);
@@ -1724,22 +1724,22 @@ CC_send_query_append(ConnectionClass *self, const char *query, QueryInfo *qi, UD
    query_buf[0] = '\0';
    if (issue_begin)
    {
-       snprintf_add(query_buf, query_buf_len, "%s;", bgncmd);
+       snprintfcat(query_buf, query_buf_len, "%s;", bgncmd);
        discard_next_begin = TRUE;
    }
    if (query_rollback)
    {
-       snprintf_add(query_buf, query_buf_len, "%s %s;", svpcmd, per_query_svp);
+       snprintfcat(query_buf, query_buf_len, "%s %s;", svpcmd, per_query_svp);
        discard_next_savepoint = TRUE;
    }
    strlcat(query_buf, query, query_buf_len);
    if (appendq)
    {
-       snprintf_add(query_buf, query_buf_len, ";%s", appendq);
+       snprintfcat(query_buf, query_buf_len, ";%s", appendq);
    }
    if (query_rollback)
    {
-       snprintf_add(query_buf, query_buf_len, ";%s %s", rlscmd, per_query_svp);
+       snprintfcat(query_buf, query_buf_len, ";%s %s", rlscmd, per_query_svp);
    }
 
    /* Set up notice receiver */
@@ -1998,7 +1998,7 @@ cleanup:
            if (CC_is_in_error_trans(self))
            {
                char tmpsqlbuf[100];
-               snprintf(tmpsqlbuf, sizeof(tmpsqlbuf),
+               SPRINTF_FIXED(tmpsqlbuf,
                         "%s TO %s; %s %s",
                         rbkcmd, per_query_svp,
                         rlscmd, per_query_svp);
@@ -2157,7 +2157,7 @@ CC_send_function(ConnectionClass *self, const char *fn_name, void *result_buf, i
 #define    return DONT_CALL_RETURN_FROM_HERE???
    ENTER_INNER_CONN_CS(self, func_cs_count);
 
-   snprintf(sqlbuffer, sizeof(sqlbuffer), "SELECT pg_catalog.%s%s", fn_name,
+   SPRINTF_FIXED(sqlbuffer, "SELECT pg_catalog.%s%s", fn_name,
             func_param_str[nargs]);
    for (i = 0; i < nargs; ++i)
    {
@@ -2431,9 +2431,9 @@ int   CC_discard_marked_objects(ConnectionClass *conn)
    {
        pname = conn->discardp[i];
        if ('s' == pname[0])
-           snprintf(cmd, sizeof(cmd), "DEALLOCATE \"%s\"", pname + 1);
+           SPRINTF_FIXED(cmd, "DEALLOCATE \"%s\"", pname + 1);
        else
-           snprintf(cmd, sizeof(cmd), "CLOSE \"%s\"", pname + 1);
+           SPRINTF_FIXED(cmd, "CLOSE \"%s\"", pname + 1);
        res = CC_send_query(conn, cmd, NULL, ROLLBACK_ON_ERROR | IGNORE_ABORT_ON_CONN, NULL);
        QR_Destructor(res);
        free(conn->discardp[i]);
@@ -2514,7 +2514,7 @@ LIBPQ_connect(ConnectionClass *self)
        char emsg[200];
 
        if (errmsg != NULL)
-           snprintf(emsg, sizeof(emsg), "libpq connection parameter error:%s", errmsg);
+           SPRINTF_FIXED(emsg, "libpq connection parameter error:%s", errmsg);
        else
            STRCPY_FIXED(emsg, "memory error? in PQconninfoParse");
        CC_set_error(self, CONN_OPENDB_ERROR, emsg, func);
@@ -2604,7 +2604,7 @@ LIBPQ_connect(ConnectionClass *self)
 
                        if (vals[j] != NULL && strcmp(vals[j], val) == 0)
                            continue;
-                       snprintf(emsg, sizeof(emsg), "%s parameter in pqopt option conflicts with other ordinary option", keyword);
+                       SPRINTF_FIXED(emsg, "%s parameter in pqopt option conflicts with other ordinary option", keyword);
                        CC_set_error(self, CONN_OPENDB_ERROR, emsg, func);
                        goto cleanup;
                    }
@@ -2798,7 +2798,7 @@ my_strcat(char *buf, int buflen, const char *fmt, const char *s, ssize_t len)
    {
        size_t  length = (len > 0) ? len : strlen(s);
 
-       snprintf_add(buf, buflen, fmt, length, s);
+       snprintfcat(buf, buflen, fmt, length, s);
        return buf;
    }
    return NULL;
@@ -2816,9 +2816,9 @@ my_strcat1(char *buf, int buflen, const char *fmt, const char *s1, const char *s
        ssize_t length = strlen(s);
 
        if (s1)
-           snprintf_add(buf, buflen, fmt, s1, length, s);
+           snprintfcat(buf, buflen, fmt, s1, length, s);
        else
-           snprintf_add(buf, buflen, fmt, length, s);
+           snprintfcat(buf, buflen, fmt, length, s);
        return buf;
    }
    return NULL;
@@ -3174,13 +3174,13 @@ PgDtc_two_phase_operation(void *self, int operation, const char *gxid)
    switch (operation)
    {
        case PREPARE_TRANSACTION:
-           snprintf(cmd, sizeof(cmd), "PREPARE TRANSACTION '%s'", gxid);
+           SPRINTF_FIXED(cmd, "PREPARE TRANSACTION '%s'", gxid);
            break;
        case COMMIT_PREPARED:
-           snprintf(cmd, sizeof(cmd), "COMMIT PREPARED '%s'", gxid);
+           SPRINTF_FIXED(cmd, "COMMIT PREPARED '%s'", gxid);
            break;
        case ROLLBACK_PREPARED:
-           snprintf(cmd, sizeof(cmd), "ROLLBACK PREPARED '%s'", gxid);
+           SPRINTF_FIXED(cmd, "ROLLBACK PREPARED '%s'", gxid);
            break;
    }
 
index 4d29f2a7dbda5aa959ca2709e48562d0b6f85fd6..e78c59c8204b13d075176c95100d6af46461c87c 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -415,7 +415,7 @@ stime2timestamp(const SIMPLE_TIME *st, char *str, size_t bufsize, BOOL bZone,
    }
    if (precision > 0 && st->fr)
    {
-       snprintf(precstr, sizeof(precstr), ".%09d", st->fr);
+       SPRINTF_FIXED(precstr, ".%09d", st->fr);
        if (precision < 9)
            precstr[precision + 1] = '\0';
        else if (precision > 9)
@@ -452,9 +452,9 @@ stime2timestamp(const SIMPLE_TIME *st, char *str, size_t bufsize, BOOL bZone,
                zoneint -= 3600;
        }
        if (zoneint > 0)
-           snprintf(zonestr, sizeof(zonestr), "-%02d", (int) zoneint / 3600);
+           SPRINTF_FIXED(zonestr, "-%02d", (int) zoneint / 3600);
        else
-           snprintf(zonestr, sizeof(zonestr), "+%02d", -(int) zoneint / 3600);
+           SPRINTF_FIXED(zonestr, "+%02d", -(int) zoneint / 3600);
    }
 #endif /* TIMEZONE_GLOBAL */
    if (st->y < 0)
@@ -1607,17 +1607,17 @@ inolog("2stime fr=%d\n", std_time.fr);
        switch (field_type)
        {
            case PG_TYPE_DATE:
-               len = snprintf(midtemp, midsize, "%.4d-%.2d-%.2d", std_time.y, std_time.m, std_time.d);
+               len = SPRINTF_FIXED(midtemp, "%.4d-%.2d-%.2d", std_time.y, std_time.m, std_time.d);
                break;
 
            case PG_TYPE_TIME:
-               len = snprintf(midtemp, midsize, "%.2d:%.2d:%.2d", std_time.hh, std_time.mm, std_time.ss);
+               len = SPRINTF_FIXED(midtemp, "%.2d:%.2d:%.2d", std_time.hh, std_time.mm, std_time.ss);
                if (std_time.fr > 0)
                {
                    int wdt;
                    int fr = effective_fraction(std_time.fr, &wdt);
 
-                   len = snprintf(midtemp, midsize, "%s.%0*d", midtemp, wdt, fr);
+                   len = SPRINTF_FIXED(midtemp, "%s.%0*d", midtemp, wdt, fr);
                }
                break;
 
@@ -2994,7 +2994,7 @@ inolog("type=%d concur=%d\n", stmt->options.cursor_type, stmt->options.scroll_co
        }
        if (SC_is_fetchcursor(stmt))
        {
-           snprintf_add(new_statement, qb->str_alsize, 
+           snprintfcat(new_statement, qb->str_alsize, 
                "declare \"%s\"%s cursor%s for ",
                SC_cursor_name(stmt), opt_scroll, opt_hold);
            qb->npos = strlen(new_statement);
@@ -4525,7 +4525,7 @@ mylog(" %s:C_WCHAR=%d contents=%s(%d)\n", __FUNCTION__, param_ctype, buffer, use
                    fraction /= 10;
                    prec--;
                }
-               snprintf_add(param_string, sizeof(param_string), ".%0*d", prec, fraction);
+               SPRINTFCAT_FIXED(param_string, ".%0*d", prec, fraction);
            }
            break;
        case SQL_C_GUID:
@@ -4535,7 +4535,7 @@ mylog(" %s:C_WCHAR=%d contents=%s(%d)\n", __FUNCTION__, param_ctype, buffer, use
             * "unsigned int" on others.
             */
            SQLGUID *g = (SQLGUID *) buffer;
-           snprintf (param_string, sizeof(param_string),
+           SPRINTF_FIXED (param_string,
                "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
                (unsigned int) g->Data1,
                g->Data2, g->Data3,
@@ -4641,7 +4641,7 @@ mylog("cvt_null_date_string=%d pgtype=%d send_buf=%p\n", conn->connInfo.cvt_null
            if (!send_buf)
            {
                /* it was date,time,timestamp -- use m,d,y,hh,mm,ss */
-               snprintf(tmp, sizeof(tmp), "%.4d-%.2d-%.2d %.2d:%.2d:%.2d",
+               SPRINTF_FIXED(tmp, "%.4d-%.2d-%.2d %.2d:%.2d:%.2d",
                        st.y, st.m, st.d, st.hh, st.mm, st.ss);
                send_buf = tmp;
                used = SQL_NTS;
@@ -5145,7 +5145,7 @@ convert_escape(QueryParse *qp, QueryBuild *qb)
    {
        /* Literal; return the escape part adding type cast */
        F_ExtractOldTo(qp, buf_small, ODBC_ESCAPE_END, sizeof(buf_small));
-       prtlen = snprintf(buf, sizeof(buf), "%s::date", buf_small);
+       prtlen = SPRINTF_FIXED(buf, "%s::date", buf_small);
        CVT_APPEND_DATA(qb, buf, prtlen);
        retval = QB_append_space_to_separate_identifiers(qb, qp);
    }
@@ -5153,7 +5153,7 @@ convert_escape(QueryParse *qp, QueryBuild *qb)
    {
        /* Literal; return the escape part adding type cast */
        F_ExtractOldTo(qp, buf_small, ODBC_ESCAPE_END, sizeof(buf_small));
-       prtlen = snprintf(buf, sizeof(buf), "%s::time", buf_small);
+       prtlen = SPRINTF_FIXED(buf, "%s::time", buf_small);
        CVT_APPEND_DATA(qb, buf, prtlen);
        retval = QB_append_space_to_separate_identifiers(qb, qp);
    }
@@ -5161,7 +5161,7 @@ convert_escape(QueryParse *qp, QueryBuild *qb)
    {
        /* Literal; return the escape part adding type cast */
        F_ExtractOldTo(qp, buf_small, ODBC_ESCAPE_END, sizeof(buf_small));
-       prtlen = snprintf(buf, sizeof(buf), "%s::timestamp", buf_small);
+       prtlen = SPRINTF_FIXED(buf, "%s::timestamp", buf_small);
        CVT_APPEND_DATA(qb, buf, prtlen);
        retval = QB_append_space_to_separate_identifiers(qb, qp);
    }
@@ -5178,7 +5178,7 @@ convert_escape(QueryParse *qp, QueryBuild *qb)
    {
        /* Literal; return the escape part adding type cast */
        F_ExtractOldTo(qp, buf_small, ODBC_ESCAPE_END, sizeof(buf_small));
-       prtlen = snprintf(buf, sizeof(buf), "%s %s", key, buf_small);
+       prtlen = SPRINTF_FIXED(buf, "%s %s", key, buf_small);
        CVT_APPEND_DATA(qb, buf, prtlen);
        retval = QB_append_space_to_separate_identifiers(qb, qp);
    }
index 89d68c9d78e0c42eb7c496823699f1c514e7f0c2..d3ffedf41b494a9f18792dbf2481db756be37b2c 100644 (file)
@@ -210,9 +210,9 @@ makeKeepaliveConnectString(char *target, int buflen, const ConnInfo *ci, BOOL ab
    if (ci->keepalive_interval >= 0)
    {
        if (abbrev)
-           snprintf_add(buf, buflen, ABBR_KEEPALIVEINTERVAL "=%u;", ci->keepalive_interval);
+           snprintfcat(buf, buflen, ABBR_KEEPALIVEINTERVAL "=%u;", ci->keepalive_interval);
        else
-           snprintf_add(buf, buflen, INI_KEEPALIVEINTERVAL "=%u;", ci->keepalive_interval);
+           snprintfcat(buf, buflen, INI_KEEPALIVEINTERVAL "=%u;", ci->keepalive_interval);
    }
    return target;
 }
@@ -319,7 +319,7 @@ inolog("hlen=%d", hlen);
        char    protocol_and[16];
 
        if (ci->rollback_on_error >= 0)
-           snprintf(protocol_and, sizeof(protocol_and), "7.4-%d", ci->rollback_on_error);
+           SPRINTF_FIXED(protocol_and, "7.4-%d", ci->rollback_on_error);
        else
            STRCPY_FIXED(protocol_and, "7.4");
        olen = snprintf(&connect_string[hlen], nlen, ";"
@@ -1228,7 +1228,7 @@ writeDSNinfo(const ConnInfo *ci)
                                 ODBC_INI);
 
    if (ci->rollback_on_error >= 0)
-       snprintf(temp, sizeof(temp), "7.4-%d", ci->rollback_on_error);
+       SPRINTF_FIXED(temp, "7.4-%d", ci->rollback_on_error);
    else
        STRCPY_FIXED(temp, NULL_STRING);
    SQLWritePrivateProfileString(DSN,
@@ -1266,7 +1266,7 @@ writeDSNinfo(const ConnInfo *ci)
                                 INI_INT8AS,
                                 temp,
                                 ODBC_INI);
-   snprintf(temp, sizeof(temp), "%x", getExtraOptions(ci));
+   SPRINTF_FIXED(temp, "%x", getExtraOptions(ci));
    SQLWritePrivateProfileString(DSN,
                            INI_EXTRAOPTIONS,
                             temp,
index 9e7cedc95085f5adf30d4bf156190a4258f2bb1c..c89ba77b6c8fc7100bc0c6e190c3d362b7ddf376 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -631,7 +631,7 @@ SetStatementSvp(StatementClass *stmt)
        if (need_savep)
        {
            SPRINTF_FIXED(esavepoint, "_EXEC_SVP_%p", stmt);
-           snprintf(cmd, sizeof(cmd), "SAVEPOINT %s", esavepoint);
+           SPRINTF_FIXED(cmd, "SAVEPOINT %s", esavepoint);
            res = CC_send_query(conn, cmd, NULL, 0, NULL);
            if (QR_command_maybe_successful(res))
            {
@@ -685,7 +685,7 @@ CC_is_in_trans(conn), SC_is_rb_stmt(stmt), SC_is_tc_stmt(stmt));
    {
        if (SC_started_rbpoint(stmt))
        {
-           snprintf(cmd, sizeof(cmd), "ROLLBACK to %s", esavepoint);
+           SPRINTF_FIXED(cmd, "ROLLBACK to %s", esavepoint);
            res = CC_send_query(conn, cmd, NULL, IGNORE_ABORT_ON_CONN, NULL);
            cmd_success = QR_command_maybe_successful(res);
            QR_Destructor(res);
@@ -707,7 +707,7 @@ CC_is_in_trans(conn), SC_is_rb_stmt(stmt), SC_is_tc_stmt(stmt));
 inolog("ret=%d\n", ret);
    if (SQL_NEED_DATA != ret && SC_started_rbpoint(stmt))
    {
-       snprintf(cmd, sizeof(cmd), "RELEASE %s", esavepoint);
+       SPRINTF_FIXED(cmd, "RELEASE %s", esavepoint);
        res = CC_send_query(conn, cmd, NULL, IGNORE_ABORT_ON_CONN, NULL);
        cmd_success = QR_command_maybe_successful(res);
        QR_Destructor(res);
diff --git a/info.c b/info.c
index 138767a926de4525e50c933dd7b770f130bd4bbb..50d3b29fd5900442249496c58aca5a153e8f5425 100644 (file)
--- a/info.c
+++ b/info.c
@@ -225,7 +225,7 @@ mylog("CONVERT_FUNCTIONS=" FORMAT_ULEN "\n", value);
             */
            /* version number to the dbms version string */
            /*
-           snprintf(tmp, sizeof(tmp) - 1, "%s %s", POSTGRESDRIVERVERSION, conn->pg_version);
+           SPRINTF_FIXED(tmp, "%s %s", POSTGRESDRIVERVERSION, conn->pg_version);
                         tmp[sizeof(tmp) - 1] = '\0'; */
            if (CC_fake_mss(conn))
                p = "09.00.1399";
@@ -248,7 +248,7 @@ mylog("CONVERT_FUNCTIONS=" FORMAT_ULEN "\n", value);
            break;
 
        case SQL_DRIVER_ODBC_VER:
-           snprintf(odbcver, sizeof(odbcver), "%02x.%02x", ODBCVER / 256, ODBCVER % 256);
+           SPRINTF_FIXED(odbcver, "%02x.%02x", ODBCVER / 256, ODBCVER % 256);
            /* p = DRIVER_ODBC_VER; */
            p = odbcver;
            break;
@@ -1806,7 +1806,7 @@ retry_public_schema:
    {
        schema_strcat1(tables_query, sizeof(tables_query), " and nspname %s'%.*s'", op_string, escSchemaName, szTableName, cbTableName, conn);
        if (IS_VALID_NAME(escTableName))
-           snprintf_add(tables_query, sizeof(tables_query),
+           SPRINTFCAT_FIXED(tables_query,
                     " and relname %s'%s'", op_string, escTableName);
    }
 
@@ -2248,7 +2248,7 @@ retry_public_schema:
     * have the atttypmod field)
     */
    op_string = gen_opestr(like_or_eq, conn);
-   snprintf(columns_query, sizeof(columns_query),
+   SPRINTF_FIXED(columns_query,
        "select n.nspname, c.relname, a.attname, a.atttypid, "
        "t.typname, a.attnum, a.attlen, a.atttypmod, a.attnotnull, "
        "c.relhasrules, c.relkind, c.oid, pg_get_expr(d.adbin, d.adrelid), "
@@ -2257,11 +2257,11 @@ retry_public_schema:
        "from (((pg_catalog.pg_class c "
        "inner join pg_catalog.pg_namespace n on n.oid = c.relnamespace");
    if (search_by_ids)
-       snprintf_add(columns_query, sizeof(columns_query), " and c.oid = %u", reloid);
+       SPRINTFCAT_FIXED(columns_query, " and c.oid = %u", reloid);
    else
    {
        if (escTableName)
-           snprintf_add(columns_query, sizeof(columns_query), " and c.relname %s'%s'", op_string, escTableName);
+           SPRINTFCAT_FIXED(columns_query, " and c.relname %s'%s'", op_string, escTableName);
        schema_strcat1(columns_query, sizeof(columns_query), " and n.nspname %s'%.*s'", op_string, escSchemaName, szTableName, cbTableName, conn);
    }
    STRCAT_FIXED(columns_query, ") inner join pg_catalog.pg_attribute a"
@@ -2271,10 +2271,10 @@ retry_public_schema:
    if (search_by_ids)
    {
        if (attnum != 0)
-           snprintf_add(columns_query, sizeof(columns_query), " and a.attnum = %d", attnum);
+           SPRINTFCAT_FIXED(columns_query, " and a.attnum = %d", attnum);
    }
    else if (escColumnName)
-       snprintf_add(columns_query, sizeof(columns_query), " and a.attname %s'%s'", op_string, escColumnName);
+       SPRINTFCAT_FIXED(columns_query, " and a.attname %s'%s'", op_string, escColumnName);
    STRCAT_FIXED(columns_query,
        " and a.attrelid = c.oid) inner join pg_catalog.pg_type t"
        " on t.oid = a.atttypid) left outer join pg_attrdef d"
@@ -2578,7 +2578,7 @@ mylog(" and the data=%s\n", attdef);
                    {
                        char    tmp[32];
 
-                       snprintf(tmp, sizeof(tmp), "%s identity", field_type_name);
+                       SPRINTF_FIXED(tmp, "%s identity", field_type_name);
                        set_tuplefield_string(&tuple[COLUMNS_TYPE_NAME], tmp);
                        break;
                    }
@@ -2767,7 +2767,7 @@ retry_public_schema:
 
    /* TableName cannot contain a string search pattern */
    if (escTableName)
-       snprintf_add(columns_query, sizeof(columns_query),
+       SPRINTFCAT_FIXED(columns_query,
                     " and c.relname %s'%s'", eq_string, escTableName);
    /* SchemaName cannot contain a string search pattern */
    schema_strcat1(columns_query, sizeof(columns_query), " and u.nspname %s'%.*s'", eq_string, escSchemaName, szTableName, cbTableName, conn);
@@ -3152,7 +3152,7 @@ PGAPI_Statistics(HSTMT hstmt,
    escTableName = simpleCatalogEscape((SQLCHAR *) table_name, SQL_NTS, conn);
    eq_string = gen_opestr(eqop, conn);
    escSchemaName = simpleCatalogEscape((SQLCHAR *) table_schemaname, SQL_NTS, conn);
-   snprintf(index_query, sizeof(index_query), "select c.relname, i.indkey, i.indisunique"
+   SPRINTF_FIXED(index_query, "select c.relname, i.indkey, i.indisunique"
        ", i.indisclustered, a.amname, c.relhasrules, n.nspname"
        ", c.oid, d.relhasoids, %s"
        " from pg_catalog.pg_index i, pg_catalog.pg_class c,"
@@ -3286,7 +3286,7 @@ PGAPI_Statistics(HSTMT hstmt,
        /* no index qualifier */
        set_tuplefield_string(&tuple[STATS_INDEX_QUALIFIER], GET_SCHEMA_NAME(table_schemaname));
 
-       snprintf(buf, sizeof(buf), "%s_idx_fake_oid", table_name);
+       SPRINTF_FIXED(buf, "%s_idx_fake_oid", table_name);
        set_tuplefield_string(&tuple[STATS_INDEX_NAME], buf);
 
        /*
@@ -3352,7 +3352,7 @@ PGAPI_Statistics(HSTMT hstmt,
 
                    QResultClass *res;
 
-                   snprintf(cmd, sizeof(cmd), "select pg_get_indexdef(%u, %d, true)", ioid, i);
+                   SPRINTF_FIXED(cmd, "select pg_get_indexdef(%u, %d, true)", ioid, i);
                    res = CC_send_query(conn, cmd, NULL, IGNORE_ABORT_ON_CONN, stmt);
                    if (QR_command_maybe_successful(res))
                        set_tuplefield_string(&tuple[STATS_COLUMN_NAME], QR_get_value_backend_text(res, 0, 0));
@@ -3738,7 +3738,7 @@ retry_public_schema:
                else
                    snprintf(tbqry, tsize, " where tc.oid = %u", reloid);
 
-               strlcat(tables_query,
+               STRCAT_FIXED(tables_query,
                    " AND tc.oid = i.indrelid"
                    " AND n.oid = tc.relnamespace"
                    " AND i.indisprimary = 't'"
@@ -3748,15 +3748,14 @@ retry_public_schema:
                    " AND (NOT ta.attisdropped)"
                    " AND (NOT ia.attisdropped)"
                    " AND ic.oid = i.indexrelid"
-                   " order by ia.attnum"
-                   , sizeof(tables_query));
+                   " order by ia.attnum");
                break;
            case 2:
 
                /*
                 * Simplified query to search old fashoned primary key
                 */
-               snprintf(tables_query, sizeof(tables_query), "select ta.attname, ia.attnum, ic.relname, n.nspname, NULL"
+               SPRINTF_FIXED(tables_query, "select ta.attname, ia.attnum, ic.relname, n.nspname, NULL"
                    " from pg_catalog.pg_attribute ta,"
                    " pg_catalog.pg_attribute ia, pg_catalog.pg_class ic,"
                    " pg_catalog.pg_index i, pg_catalog.pg_namespace n"
@@ -3905,13 +3904,13 @@ getClientColumnName(ConnectionClass *conn, UInt4 relid, char *serverColumnName,
    }
    if (!conn->server_encoding)
        return ret;
-   snprintf(query, sizeof(query), "SET CLIENT_ENCODING TO '%s'", conn->server_encoding);
+   SPRINTF_FIXED(query, "SET CLIENT_ENCODING TO '%s'", conn->server_encoding);
    bError = (!QR_command_maybe_successful((res = CC_send_query(conn, query, NULL, flag, NULL))));
    QR_Destructor(res);
    eq_string = gen_opestr(eqop, conn);
    if (!bError && continueExec)
    {
-       snprintf(query, sizeof(query), "select attnum from pg_attribute "
+       SPRINTF_FIXED(query, "select attnum from pg_attribute "
            "where attrelid = %u and attname %s'%s'",
            relid, eq_string, serverColumnName);
        if (res = CC_send_query(conn, query, NULL, flag, NULL), QR_command_maybe_successful(res))
@@ -3929,12 +3928,12 @@ getClientColumnName(ConnectionClass *conn, UInt4 relid, char *serverColumnName,
    }
    continueExec = (continueExec && !bError);
    /* restore the cleint encoding */
-   snprintf(query, sizeof(query), "SET CLIENT_ENCODING TO '%s'", conn->original_client_encoding);
+   SPRINTF_FIXED(query, "SET CLIENT_ENCODING TO '%s'", conn->original_client_encoding);
    bError = (!QR_command_maybe_successful((res = CC_send_query(conn, query, NULL, flag, NULL))));
    QR_Destructor(res);
    if (bError || !continueExec)
        return ret;
-   snprintf(query, sizeof(query), "select attname from pg_attribute where attrelid = %u and attnum = %s", relid, saveattnum);
+   SPRINTF_FIXED(query, "select attname from pg_attribute where attrelid = %u and attnum = %s", relid, saveattnum);
    if (res = CC_send_query(conn, query, NULL, flag, NULL), QR_command_maybe_successful(res))
    {
        if (QR_get_num_cached_tuples(res) > 0)
@@ -4112,7 +4111,7 @@ PGAPI_ForeignKeys_old(HSTMT hstmt,
        escFkTableName = simpleCatalogEscape((SQLCHAR *) fk_table_needed, SQL_NTS, conn);
        schema_strcat(schema_needed, sizeof(schema_needed), "%.*s", szFkTableOwner, cbFkTableOwner, szFkTableName, cbFkTableName, conn);
        escSchemaName = simpleCatalogEscape((SQLCHAR *) schema_needed, SQL_NTS, conn);
-       snprintf(tables_query, sizeof(tables_query), "SELECT    pt.tgargs, "
+       SPRINTF_FIXED(tables_query, "SELECT pt.tgargs, "
            "       pt.tgnargs, "
            "       pt.tgdeferrable, "
            "       pt.tginitdeferred, "
@@ -4440,7 +4439,7 @@ PGAPI_ForeignKeys_old(HSTMT hstmt,
        escPkTableName = simpleCatalogEscape((SQLCHAR *) pk_table_needed, SQL_NTS, conn);
        schema_strcat(schema_needed, sizeof(schema_needed), "%.*s", szPkTableOwner, cbPkTableOwner, szPkTableName, cbPkTableName, conn);
        escSchemaName = simpleCatalogEscape((SQLCHAR *) schema_needed, SQL_NTS, conn);
-       snprintf(tables_query, sizeof(tables_query), "SELECT    pt.tgargs, "
+       SPRINTF_FIXED(tables_query, "SELECT pt.tgargs, "
            "   pt.tgnargs, "
            "   pt.tgdeferrable, "
            "   pt.tginitdeferred, "
@@ -4902,16 +4901,16 @@ PGAPI_ProcedureColumns(HSTMT hstmt,
               " p.pronamespace = n.oid  and"
               " (not proretset) and");
 #endif /* PRORET_COUNT */
-   snprintf_add(proc_query, sizeof(proc_query),
+   SPRINTFCAT_FIXED(proc_query,
                 " has_function_privilege(p.oid, 'EXECUTE')");
    if (IS_VALID_NAME(escSchemaName))
-       snprintf_add(proc_query, sizeof(proc_query),
+       SPRINTFCAT_FIXED(proc_query,
                 " and nspname %s'%s'",
                 op_string, escSchemaName);
    if (escProcName)
-       snprintf_add(proc_query, sizeof(proc_query),
+       SPRINTFCAT_FIXED(proc_query,
                     " and proname %s'%s'", op_string, escProcName);
-   snprintf_add(proc_query, sizeof(proc_query),
+   SPRINTFCAT_FIXED(proc_query,
                 " order by nspname, proname, p.oid, attnum");
 
    if (escSchemaName)
@@ -5263,7 +5262,7 @@ PGAPI_Procedures(HSTMT hstmt,
      " where pg_proc.pronamespace = pg_namespace.oid");
    schema_strcat1(proc_query, sizeof(proc_query), " and nspname %s'%.*s'", op_string, escSchemaName, szProcName, cbProcName, conn);
    if (IS_VALID_NAME(escProcName))
-       snprintf_add(proc_query, sizeof(proc_query),
+       SPRINTFCAT_FIXED(proc_query,
                 " and proname %s'%s'", op_string, escProcName);
 
    res = CC_send_query(conn, proc_query, NULL, IGNORE_ABORT_ON_CONN, stmt);
@@ -5442,7 +5441,7 @@ retry_public_schema:
        schema_strcat1(proc_query, sizeof(proc_query), " nspname %s'%.*s' and", op_string, escSchemaName, szTableName, cbTableName, conn);
 
    if (escTableName)
-       snprintf_add(proc_query, sizeof(proc_query), " relname %s'%s' and", op_string, escTableName);
+       SPRINTFCAT_FIXED(proc_query, " relname %s'%s' and", op_string, escTableName);
    STRCAT_FIXED(proc_query, " pg_namespace.oid = relnamespace and relkind in ('r', 'v') and");
    if ((!escTableName) && (!escSchemaName))
        STRCAT_FIXED(proc_query, " nspname not in ('pg_catalog', 'information_schema') and");
@@ -5522,7 +5521,7 @@ retry_public_schema:
                int     i;
                char    *grolist, *uid, *delm;
 
-               snprintf(proc_query, sizeof(proc_query) - 1, "select grolist from pg_group where groname = '%s'", user);
+               SPRINTF_FIXED(proc_query, "select grolist from pg_group where groname = '%s'", user);
                if (gres = CC_send_query(conn, proc_query, NULL, IGNORE_ABORT_ON_CONN, stmt), !QR_command_maybe_successful(gres))
                {
                    grolist = QR_get_value_backend_text(gres, 0, 0);
@@ -5706,14 +5705,14 @@ PGAPI_ForeignKeys_new(HSTMT hstmt,
    }
 
    if (NULL != CurrCat(conn))
-       snprintf(catName, sizeof(catName), "'%s'::name", CurrCat(conn));
+       SPRINTF_FIXED(catName, "'%s'::name", CurrCat(conn));
    else
        STRCPY_FIXED(catName, "NULL::name");
    STRCPY_FIXED(scmName1, "n2.nspname");
    STRCPY_FIXED(scmName2, "n1.nspname");
    escSchemaName = simpleCatalogEscape((SQLCHAR *) schema_needed, SQL_NTS, conn);
 
-   snprintf(tables_query, sizeof(tables_query),
+   SPRINTF_FIXED(tables_query,
        "select"
        "   %s as PKTABLE_CAT"
        ",\n    %s as PKTABLE_SCHEM"
@@ -5806,7 +5805,7 @@ PGAPI_ForeignKeys_new(HSTMT hstmt,
    {
        free(escTableName);
        escTableName = simpleCatalogEscape((SQLCHAR *) pk_table_needed, SQL_NTS, conn);
-       snprintf_add(tables_query, sizeof(tables_query),
+       SPRINTFCAT_FIXED(tables_query,
                "\n where c2.relname %s'%s'",
                eq_string, escTableName);
    }
index 5a1bf247cce9a70dcee0b7bdfeb7fd9e95d943ea..30e9b83a43d92efe6782823c6734bdc36d16a88b 100644 (file)
--- a/loadlib.c
+++ b/loadlib.c
@@ -17,6 +17,7 @@
 
 #include "loadlib.h"
 #include "pgenlist.h"
+#include "misc.h"
 
 #ifdef  WIN32
 #ifdef  _MSC_VER
@@ -112,7 +113,7 @@ HMODULE MODULE_load_from_psqlodbc_path(const char *module_name)
 
        _splitpath(szFileName, drive, dir, NULL, NULL);
        GetSystemDirectory(sysdir, MAX_PATH);
-       snprintf(szFileName, sizeof(szFileName), "%s%s%s.dll", drive, dir, module_name);
+       SPRINTF_FIXED(szFileName, "%s%s%s.dll", drive, dir, module_name);
        if (_strnicmp(szFileName, sysdir, strlen(sysdir)) != 0)
        {
            hmodule = LoadLibraryEx(szFileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
diff --git a/misc.c b/misc.c
index f359ceb782a2edcc3850147014ec8007954dfee3..926c288e0cf5ab0f9a809f1e4e6dd3aa305e8400 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -158,12 +158,12 @@ my_trim(char *s)
 }
 
 /*
- * snprintf_add is a extension to snprintf
+ * snprintfcat is a extension to snprintf
  * It add format to buf at given pos
  */
 
 int
-snprintf_add(char *buf, size_t size, const char *format, ...)
+snprintfcat(char *buf, size_t size, const char *format, ...)
 {
    int len;
    size_t pos = strlen(buf);
@@ -176,7 +176,7 @@ snprintf_add(char *buf, size_t size, const char *format, ...)
 }
 
 /*
- * snprintf_addlen is a extension to snprintf
+ * snprintf_len is a extension to snprintf
  * It returns strlen of buf every time (not -1 when truncated)
  */
 
diff --git a/misc.h b/misc.h
index 2a3d83fbc804f56fa997884e9991b1a5dbb69cb0..2f61a6151cc910c43f1625707d2a99285da809b3 100644 (file)
--- a/misc.h
+++ b/misc.h
@@ -22,7 +22,7 @@ char     *strncpy_null(char *dst, const char *src, ssize_t len);
 #ifndef    HAVE_STRLCAT
 size_t     strlcat(char *, const char *, size_t);
 #endif /* HAVE_STRLCAT */
-int       snprintf_add(char *buf, size_t size, const char *format, ...);
+int       snprintfcat(char *buf, size_t size, const char *format, ...);
 size_t    snprintf_len(char *buf, size_t size, const char *format, ...);
 
 char      *my_trim(char *string);
@@ -85,10 +85,10 @@ FUNCTION_BEGIN_MACRO \
 FUNCTION_END_MACRO
 
 /* macro to safely sprintf() & cat to fixed arrays. */
-#define    SPRINTF_FIXEDCAT(to, ...) \
+#define    SPRINTFCAT_FIXED(to, ...) \
 FUNCTION_BEGIN_MACRO \
    CHECK_NOT_CHAR_P(to) \
-   snprintf_add((to), sizeof(to), __VA_ARGS__) \
+   snprintfcat((to), sizeof(to), __VA_ARGS__) \
 FUNCTION_END_MACRO
 
 #define    ITOA_FIXED(to, from) \
diff --git a/mylog.c b/mylog.c
index 13ac9d2be1033b37374b56377715ef50bd4a21fc..db9346b18e57ce977eb978d04950c4d2222d6d12 100644 (file)
--- a/mylog.c
+++ b/mylog.c
@@ -78,7 +78,7 @@ generate_filename(const char *dirname, const char *prefix, char *filename, size_
    if (ptr)
        strlcat(filename, ptr->pw_name, filenamelen);
 #endif
-   snprintf_add(filename, filenamelen, "%u%s", pid, ".log");
+   snprintfcat(filename, filenamelen, "%u%s", pid, ".log");
    return;
 }
 
@@ -225,7 +225,7 @@ static void MLOG_open()
        int lasterror = GENERAL_ERRNO;
  
        open_error = TRUE;
-       snprintf(errbuf, sizeof(errbuf), "%s open error %d\n", filebuf, lasterror);
+       SPRINTF_FIXED(errbuf, "%s open error %d\n", filebuf, lasterror);
        generate_homefile(MYLOGFILE, filebuf, sizeof(filebuf));
        MLOGFP = fopen(filebuf, PG_BINARY_A);
    }
index b7c8f0bdff88f301e766fab20ff3f5c1817fad44..2347df5cc5cab2ddb9073bf0f0063ef4900d70ca 100644 (file)
--- a/odbcapi.c
+++ b/odbcapi.c
@@ -46,7 +46,7 @@ BOOL  SC_connection_lost_check(StatementClass *stmt, const char *funcname)
    if (NULL != conn->pqconn)
        return  FALSE;
    SC_clear_error(stmt);
-   snprintf(message, sizeof(message), "%s unable due to the connection lost", funcname);
+   SPRINTF_FIXED(message, "%s unable due to the connection lost", funcname);
    SC_set_error(stmt, STMT_COMMUNICATION_ERROR, message, funcname);
    return TRUE;
 }
index eebc8fa8f1b534e9e5c9155f221e521dadb8bc5f..726bc05b87e0723fbd2ee478d312f2b5723f7a65 100644 (file)
@@ -20,6 +20,7 @@
 #include "pgapifunc.h"
 #include "connection.h"
 #include "statement.h"
+#include "misc.h"
 
 
 RETCODE    SQL_API
@@ -256,7 +257,7 @@ SQLGetDiagRecW(SQLSMALLINT fHandleType,
            {
                char errc[32];
 
-               snprintf(errc, sizeof(errc), "Error: SqlState=%s", qstr_ansi);
+               SPRINTF_FIXED(errc, "Error: SqlState=%s", qstr_ansi);
                tlen = utf8_to_ucs2(errc, -1, szErrorMsg, cbErrorMsgMax);
            }
        }
diff --git a/parse.c b/parse.c
index 484637590e012dbd8ddc3a105876a6dd2011e9cb..3380c9fada663b2137ccd9dfd5767e64dc2651d3 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -391,7 +391,7 @@ static BOOL CheckHasOids(StatementClass * stmt)
    if (!stmt->ti || !stmt->ti[0])
        return FALSE;
    ti = stmt->ti[0];
-   snprintf(query, sizeof(query),
+   SPRINTF_FIXED(query,
             "select relhasoids, c.oid, relhassubclass from pg_class c, pg_namespace n where relname = '%s' and nspname = '%s' and c.relnamespace = n.oid",
             SAFE_NAME(ti->table_name), SAFE_NAME(ti->schema_name));
    res = CC_send_query(conn, query, NULL, ROLLBACK_ON_ERROR | IGNORE_ABORT_ON_CONN, NULL);
@@ -768,7 +768,7 @@ COL_INFO **coli)
            /*
             * We also have to check as follows.
             */
-           snprintf(token, sizeof(token),
+           SPRINTF_FIXED(token,
                     "select nspname from pg_namespace n, pg_class c"
                     " where c.relnamespace=n.oid and c.oid='\"%s\"'::regclass",
                     SAFE_NAME(table_name));
index 885cc491bdeaef425ad66ca5382ae8b723c40c38..454a8114e245ceaa69f61289f98cd67299201d2e 100644 (file)
--- a/pgapi30.c
+++ b/pgapi30.c
@@ -1802,7 +1802,7 @@ PGAPI_SetConnectAttr(HDBC ConnectionHandle,
    if (unsupported)
    {
        char    msg[64];
-       snprintf(msg, sizeof(msg), "Couldn't set unsupported connect attribute " FORMAT_INTEGER, Attribute);
+       SPRINTF_FIXED(msg, "Couldn't set unsupported connect attribute " FORMAT_INTEGER, Attribute);
        CC_set_error(conn, CONN_OPTION_NOT_FOR_THE_DRIVER, msg, func);
        return SQL_ERROR;
    }
index bc253f5e8cb158ce61d166bbebca09c341bc5a14..568b8ffe12a6a6024e5df3ffb81293557d1477f2 100644 (file)
@@ -3,6 +3,7 @@
 #include   "psqlodbc.h"
 #include   "dlg_specific.h"
 #include   "loadlib.h"
+#include   "misc.h"
 
 HINSTANCE s_hModule;       /* Saved module handle. */
 
@@ -85,16 +86,16 @@ DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
                    char drive[_MAX_DRIVE], dir[_MAX_DIR];
 
                    _splitpath(dllPath, drive, dir, NULL, NULL);
-                   snprintf(dllPath, sizeof(dllPath), "%s%slibpq.dll", drive, dir);
+                   SPRINTF_FIXED(dllPath, "%s%slibpq.dll", drive, dir);
                    if (s_hLModule = LoadLibraryEx(dllPath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH), s_hLModule == NULL)
                    {
                        mylog("libpq in the folder %s%s couldn't be loaded\n", drive, dir);
-                       snprintf(message, sizeof(message), "libpq in neither %s nor %s%s could be loaded", PG_BIN, drive, dir);
+                       SPRINTF_FIXED(message, "libpq in neither %s nor %s%s could be loaded", PG_BIN, drive, dir);
                    }
                }
 #ifdef PG_BIN
                else
-                   snprintf(message, sizeof(message),  "libpq in the folder %s couldn't be loaded", PG_BIN);
+                   SPRINTF_FIXED(message, "libpq in the folder %s couldn't be loaded", PG_BIN);
 #endif /* PG_BIN */
                if (message[0])
                    MessageBox(NULL, message, "psqlsetup", MB_OK);
index 18195d4cd214ac46d0260e1d19ffa21025619533..ff48814bd76b8bffd5ff8a6e131638f8c17beb85 100644 (file)
--- a/qresult.c
+++ b/qresult.c
@@ -498,7 +498,7 @@ QR_free_memory(QResultClass *self)
        {
            char    plannm[32];
 
-           snprintf(plannm, sizeof(plannm), "_KEYSET_%p", self);
+           SPRINTF_FIXED(plannm, "_KEYSET_%p", self);
            if (CC_is_in_error_trans(conn))
            {
                CC_mark_a_object_to_discard(conn, 's',plannm);
@@ -508,7 +508,7 @@ QR_free_memory(QResultClass *self)
                QResultClass    *res;
                char        cmd[64];
 
-               snprintf(cmd, sizeof(cmd), "DEALLOCATE \"%s\"", plannm);
+               SPRINTF_FIXED(cmd, "DEALLOCATE \"%s\"", plannm);
                res = CC_send_query(conn, cmd, NULL, IGNORE_ABORT_ON_CONN | ROLLBACK_ON_ERROR, NULL);
                QR_Destructor(res);
            }
@@ -742,7 +742,7 @@ QR_close(QResultClass *self)
            if (QR_needs_survival_check(self))
                flag = ROLLBACK_ON_ERROR | IGNORE_ABORT_ON_CONN;
 
-           snprintf(buf, sizeof(buf), "close \"%s\"", QR_get_cursor(self));
+           SPRINTF_FIXED(buf, "close \"%s\"", QR_get_cursor(self));
            /* End the transaction if there are no cursors left on this conn */
            if (CC_is_in_trans(conn) &&
                CC_does_autocommit(conn) &&
@@ -751,7 +751,7 @@ QR_close(QResultClass *self)
                mylog("QResult: END transaction on conn=%p\n", conn);
                if ((ROLLBACK_ON_ERROR & flag) == 0)
                {
-                   strlcat(buf, ";commit", sizeof(buf));
+                   STRCAT_FIXED(buf, ";commit");
                    flag |= END_WITH_COMMIT;
                    QR_set_cursor(self, NULL);
                }
@@ -905,7 +905,7 @@ SQLLEN  QR_move_cursor_to_last(QResultClass *self, StatementClass *stmt)
    if (QR_once_reached_eof(self) &&
        self->cursTuple >= self->num_total_read)
        return 0;
-   snprintf(movecmd, sizeof(movecmd),
+   SPRINTF_FIXED(movecmd,
         "move all in \"%s\"", QR_get_cursor(self));
    res = CC_send_query(conn, movecmd, NULL, 0, stmt);
    if (!QR_command_maybe_successful(res))
@@ -991,17 +991,17 @@ inolog("in total_read=%d cursT=%d currT=%d ad=%d total=%d rowsetSize=%d\n", self
            else
                self->cache_size = req_size;
 inolog("cache=%d rowset=%d movement=" FORMAT_ULEN "\n", self->cache_size, req_size, movement);
-           snprintf(movecmd, sizeof(movecmd),
+           SPRINTF_FIXED(movecmd,
                     "move backward " FORMAT_ULEN " in \"%s\"",
                     movement, QR_get_cursor(self));
        }
        else if (QR_is_moving_forward(self))
-           snprintf(movecmd, sizeof(movecmd),
+           SPRINTF_FIXED(movecmd,
                     "move " FORMAT_ULEN " in \"%s\"",
                     movement, QR_get_cursor(self));
        else
        {
-           snprintf(movecmd, sizeof(movecmd),
+           SPRINTF_FIXED(movecmd,
                     "move all in \"%s\"",
                     QR_get_cursor(self));
            movement = INT_MAX;
@@ -1141,7 +1141,7 @@ inolog("clear obsolete %d tuples\n", num_backend_rows);
        RETURN(FALSE)
 
    /* Send a FETCH command to get more rows */
-   snprintf(fetch, sizeof(fetch),
+   SPRINTF_FIXED(fetch,
             "fetch %d in \"%s\"",
             fetch_size, QR_get_cursor(self));
 
@@ -1400,7 +1400,7 @@ nextrow:
                        char    emsg[128];
 
                        QR_set_rstatus(self, PORES_INTERNAL_ERROR);
-                       snprintf(emsg, sizeof(emsg), "Internal Error -- this_keyset == NULL ci_num_fields=%d effective_cols=%d", ci_num_fields, effective_cols);
+                       SPRINTF_FIXED(emsg, "Internal Error -- this_keyset == NULL ci_num_fields=%d effective_cols=%d", ci_num_fields, effective_cols);
                        QR_set_message(self, emsg);
                        return FALSE;
                    }
index 5219319087acdb465811aa724055af06b63e887a..56750e45608474037f728ccee8edfa44e218900b 100644 (file)
--- a/results.c
+++ b/results.c
@@ -327,7 +327,7 @@ inolog("answering bookmark info\n");
        if (icol >= QR_NumPublicResultCols(res))
        {
            SC_set_error(stmt, STMT_INVALID_COLUMN_NUMBER_ERROR, "Invalid column number in DescribeCol.", func);
-           snprintf(buf, sizeof(buf), "Col#=%d, #Cols=%d,%d keys=%d", icol, QR_NumResultCols(res), QR_NumPublicResultCols(res), res->num_key_fields);
+           SPRINTF_FIXED(buf, "Col#=%d, #Cols=%d,%d keys=%d", icol, QR_NumResultCols(res), QR_NumPublicResultCols(res), res->num_key_fields);
            SC_log_error(func, buf, stmt);
            result = SQL_ERROR;
            goto cleanup;
@@ -2186,7 +2186,7 @@ ti_quote(StatementClass *stmt, OID tableoid)
        QResultClass    *res;
        char    *ret = "";
 
-       snprintf(query, sizeof(query), "select relname, nspname from pg_class c, pg_namespace n where c.oid=%u and c.relnamespace=n.oid", tableoid);
+       SPRINTF_FIXED(query, "select relname, nspname from pg_class c, pg_namespace n where c.oid=%u and c.relnamespace=n.oid", tableoid);
        res = CC_send_query(SC_get_conn(stmt), query, NULL, 0, stmt);
        if (QR_command_maybe_successful(res) &&
            QR_get_num_cached_tuples(res) == 1)
@@ -2211,14 +2211,14 @@ static BOOL tupleExists(StatementClass *stmt, const KeySet *keyset)
    RETCODE     ret = FALSE;
    const char *bestqual = GET_NAME(ti->bestqual);
 
-   snprintf(selstr, sizeof(selstr),
+   SPRINTF_FIXED(selstr,
             "select 1 from %s where ctid = '(%u,%u)'",
             ti_quote(stmt, keyset->oid),
             keyset->blocknum, keyset->offset);
    if (NULL != bestqual && 0 != keyset->oid && !TI_has_subclass(ti))
    {
-       snprintf_add(selstr, sizeof(selstr), " and ");
-       snprintf_add(selstr, sizeof(selstr), bestqual, keyset->oid);
+       SPRINTFCAT_FIXED(selstr, " and ");
+       SPRINTFCAT_FIXED(selstr, bestqual, keyset->oid);
    }
    res = CC_send_query(SC_get_conn(stmt), selstr, NULL, 0, NULL);
    if (QR_command_maybe_successful(res) && 1 == res->num_cached_rows)
@@ -2960,7 +2960,7 @@ inolog("->(%u, %u)\n", wkey->blocknum, wkey->offset);
                    char    tidval[32];
                    Oid oid = wkey->oid;
 
-                   snprintf(tidval, sizeof(tidval),
+                   SPRINTF_FIXED(tidval,
                             "(%u,%u)", wkey->blocknum, wkey->offset);
                    qres = positioned_load(stmt, 0, &oid, tidval);
                    if (QR_command_maybe_successful(qres) &&
@@ -3027,7 +3027,7 @@ inolog("%s bestitem=%s bestqual=%s\n", func, SAFE_NAME(ti->bestitem), SAFE_NAME(
    else
    {
        STRCPY_FIXED(oideqstr, andqual);
-       snprintf_add(oideqstr, sizeof(oideqstr), bestqual, *oidint);
+       SPRINTFCAT_FIXED(oideqstr, bestqual, *oidint);
    }
    len = strlen(load_stmt);
    len += strlen(oideqstr);
@@ -3094,7 +3094,7 @@ inolog("%s bestitem=%s bestqual=%s\n", func, SAFE_NAME(ti->bestitem), SAFE_NAME(
        else if (bestqual && oidint)
        {
            snprintf(selstr, len, "%s where ", load_stmt);
-           snprintf_add(selstr, len, bestqual, *oidint);
+           snprintfcat(selstr, len, bestqual, *oidint);
        }
        else
        {
@@ -3211,7 +3211,7 @@ SC_pos_reload_with_key(StatementClass *stmt, SQLULEN global_ridx, UInt2 *count,
        char tid[32];
 
        oidint = keyset->oid;
-       snprintf(tid, sizeof(tid), "(%u,%hu)", keyset->blocknum, keyset->offset);
+       SPRINTF_FIXED(tid, "(%u,%hu)", keyset->blocknum, keyset->offset);
        qres = positioned_load(stmt, 0, &oidint, tid);
    }
    else
@@ -3405,13 +3405,13 @@ static SQLLEN LoadFromKeyset(StatementClass *stmt, QResultClass * res, int rows_
                    {
                        strlcat(qval, j ? ",tid" : "(tid", allen);
                    }
-                   snprintf_add(qval, allen, ") as %s where ctid in ", stmt->load_statement);
+                   snprintfcat(qval, allen, ") as %s where ctid in ", stmt->load_statement);
                    for (j = 0; j < keys_per_fetch; j++)
                    {
                        if (j == 0)
                            strlcat(qval, "($1", allen);
                        else
-                           snprintf_add(qval, allen, ",$%d", j + 1);
+                           snprintfcat(qval, allen, ",$%d", j + 1);
                    }
                    strlcat(qval, ")", allen);
                    qres = CC_send_query(conn, qval, NULL, 0, stmt);
@@ -3446,9 +3446,9 @@ static SQLLEN LoadFromKeyset(StatementClass *stmt, QResultClass * res, int rows_
        {
            getTid(res, kres_ridx, &blocknum, &offset);
            if (rowc)
-               snprintf_add(qval, allen, ",'(%u,%u)'", blocknum, offset);
+               snprintfcat(qval, allen, ",'(%u,%u)'", blocknum, offset);
            else
-               snprintf_add(qval, allen, "'(%u,%u)'", blocknum, offset);
+               snprintfcat(qval, allen, "'(%u,%u)'", blocknum, offset);
            rowc++;
            rcnt++;
        }
@@ -3570,9 +3570,9 @@ mylog(" %s in rows_per_fetch=%d limitrow=%d\n", __FUNCTION__, rows_per_fetch, li
            oid = new_oid;
        getTid(res, kres_ridx, &blocknum, &offset);
        if (rowc)
-           snprintf_add(qval, allen, ",'(%u,%u)'", blocknum, offset);
+           snprintfcat(qval, allen, ",'(%u,%u)'", blocknum, offset);
        else
-           snprintf_add(qval, allen, "'(%u,%u)'", blocknum, offset);
+           snprintfcat(qval, allen, "'(%u,%u)'", blocknum, offset);
        rowc++;
        rcnt++;
    }
@@ -3983,7 +3983,7 @@ SC_pos_update(StatementClass *stmt,
 
    ti = s.stmt->ti[0];
 
-   snprintf(updstr, sizeof(updstr),
+   SPRINTF_FIXED(updstr,
             "update %s set", ti_quote(stmt, oid));
 
    num_cols = s.irdflds->nfields;
@@ -4001,10 +4001,10 @@ SC_pos_update(StatementClass *stmt,
            if (*used != SQL_IGNORE && fi[i]->updatable)
            {
                if (upd_cols)
-                   snprintf_add(updstr, sizeof(updstr),
+                   SPRINTFCAT_FIXED(updstr,
                                 ", \"%s\" = ?", GET_NAME(fi[i]->column_name));
                else
-                   snprintf_add(updstr, sizeof(updstr),
+                   SPRINTFCAT_FIXED(updstr,
                                 " \"%s\" = ?", GET_NAME(fi[i]->column_name));
                upd_cols++;
            }
@@ -4026,21 +4026,21 @@ SC_pos_update(StatementClass *stmt,
        const char *bestqual = GET_NAME(ti->bestqual);
        int unknown_sizes = ci->drivers.unknown_sizes;
 
-       snprintf_add(updstr, sizeof(updstr),
+       SPRINTFCAT_FIXED(updstr,
                     " where ctid = '(%u, %u)'",
                     blocknum, pgoffset);
        if (bestqual)
        {
-           snprintf_add(updstr, sizeof(updstr), " and ");
-           snprintf_add(updstr, sizeof(updstr), bestqual, oid);
+           SPRINTFCAT_FIXED(updstr, " and ");
+           SPRINTFCAT_FIXED(updstr, bestqual, oid);
        }
        if (PG_VERSION_GE(conn, 8.2))
        {
-           snprintf_add(updstr, sizeof(updstr), " returning ctid");
+           SPRINTFCAT_FIXED(updstr, " returning ctid");
            if (bestitem)
            {
-               snprintf_add(updstr, sizeof(updstr), ", ");
-               snprintf_add(updstr, sizeof(updstr), "\"%s\"", bestitem);
+               SPRINTFCAT_FIXED(updstr, ", ");
+               SPRINTFCAT_FIXED(updstr, "\"%s\"", bestitem);
            }
        }
        mylog("updstr=%s\n", updstr);
@@ -4177,13 +4177,13 @@ SC_pos_delete(StatementClass *stmt,
        blocknum = keyset->blocknum;
        offset = keyset->offset;
    }
-   snprintf(dltstr, sizeof(dltstr),
+   SPRINTF_FIXED(dltstr,
             "delete from %s where ctid = '(%u, %u)'",
             ti_quote(stmt, oid), blocknum, offset);
    if (bestqual && !TI_has_subclass(ti))
    {
-       snprintf_add(dltstr, sizeof(dltstr), " and ");
-       snprintf_add(dltstr, sizeof(dltstr), bestqual, oid);
+       SPRINTFCAT_FIXED(dltstr, " and ");
+       SPRINTFCAT_FIXED(dltstr, bestqual, oid);
    }
 
    mylog("dltstr=%s\n", dltstr);
@@ -4294,7 +4294,7 @@ irow_insert(RETCODE ret, StatementClass *stmt, StatementClass *istmt,
            {
                KeySetSet(tres->backend_tuples, QR_NumResultCols(tres), QR_NumResultCols(tres), &keys, TRUE);
                oid = keys.oid;
-               snprintf(tidv, sizeof(tidv), "(%u,%hu)", keys.blocknum, keys.offset);
+               SPRINTF_FIXED(tidv, "(%u,%hu)", keys.blocknum, keys.offset);
                tidval = tidv;
            }
            if (0 != oid)
@@ -4440,7 +4440,7 @@ SC_pos_add(StatementClass *stmt,
    num_cols = s.irdflds->nfields;
    conn = SC_get_conn(s.stmt);
 
-   snprintf(addstr, sizeof(addstr),
+   SPRINTF_FIXED(addstr,
             "insert into %s (",
             ti_quote(s.stmt, 0));
    if (PGAPI_AllocStmt(conn, &hstmt, 0) != SQL_SUCCESS)
@@ -4476,10 +4476,10 @@ SC_pos_add(StatementClass *stmt,
                /* fieldtype = QR_get_field_type(s.res, i); */
                fieldtype = getEffectiveOid(conn, fi[i]);
                if (add_cols)
-                   snprintf_add(addstr, sizeof(addstr),
+                   SPRINTFCAT_FIXED(addstr,
                                 ", \"%s\"", GET_NAME(fi[i]->column_name));
                else
-                   snprintf_add(addstr, sizeof(addstr),
+                   SPRINTFCAT_FIXED(addstr,
                                 "\"%s\"", GET_NAME(fi[i]->column_name));
                PIC_set_pgtype(ipdopts->parameters[add_cols], fieldtype);
                PGAPI_BindParameter(hstmt,
@@ -4502,25 +4502,25 @@ SC_pos_add(StatementClass *stmt,
    ENTER_INNER_CONN_CS(conn, func_cs_count);
    if (add_cols > 0)
    {
-       snprintf_add(addstr, sizeof(addstr), ") values (");
+       SPRINTFCAT_FIXED(addstr, ") values (");
        for (i = 0; i < add_cols; i++)
        {
            if (i)
-               snprintf_add(addstr, sizeof(addstr), ", ?");
+               SPRINTFCAT_FIXED(addstr, ", ?");
            else
-               snprintf_add(addstr, sizeof(addstr), "?");
+               SPRINTFCAT_FIXED(addstr, "?");
        }
-       snprintf_add(addstr, sizeof(addstr), ")");
+       SPRINTFCAT_FIXED(addstr, ")");
        if (PG_VERSION_GE(conn, 8.2))
        {
            TABLE_INFO  *ti = stmt->ti[0];
            const char *bestitem = GET_NAME(ti->bestitem);
 
-           snprintf_add(addstr, sizeof(addstr), " returning ctid");
+           SPRINTFCAT_FIXED(addstr, " returning ctid");
            if (bestitem)
            {
-               snprintf_add(addstr, sizeof(addstr), ", ");
-               snprintf_add(addstr, sizeof(addstr), "\"%s\"", bestitem);
+               SPRINTFCAT_FIXED(addstr, ", ");
+               SPRINTFCAT_FIXED(addstr, "\"%s\"", bestitem);
            }
        }
        mylog("addstr=%s\n", addstr);
diff --git a/setup.c b/setup.c
index eec37265029e8b35ffdb5ec20373b0944402dcc1..bfaecb8fe2be202731353b5bbe1e83d7c694ae2b 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -699,7 +699,7 @@ SetDriverAttributes(LPCSTR lpszDriver, DWORD *pErrorCode, LPSTR message, WORD cb
        goto cleanup;
    if (!SQLWritePrivateProfileString(lpszDriver, "ConnectFunctions", "YYN", ODBCINST_INI))
        goto cleanup;
-   snprintf(ver_string, sizeof(ver_string), "%02x.%02x",
+   SPRINTF_FIXED(ver_string, "%02x.%02x",
                 ODBCVER / 256,
                 ODBCVER % 256);
    if (!SQLWritePrivateProfileString(lpszDriver, "DriverODBCVer",
index b06beab56b66c54cdc043b8089520b8821e118ea..dc6a8056afa185619123522c486112bf2e4c49ac 100644 (file)
@@ -1876,7 +1876,7 @@ SC_execute(StatementClass *self)
    {
        char query[64];
 
-       snprintf(query, sizeof(query), "SET statement_timeout = %d",
+       SPRINTF_FIXED(query, "SET statement_timeout = %d",
                 (int) self->options.stmt_timeout * 1000);
        res = CC_send_query(conn, query, NULL, 0, NULL);
        if (QR_command_maybe_successful(res))
@@ -1936,7 +1936,7 @@ SC_execute(StatementClass *self)
            qi.result_in = NULL;
            qi.cursor = SC_cursor_name(self);
            qi.fetch_size = qi.row_size = ci->drivers.fetch_max;
-           snprintf(fetch, sizeof(fetch),
+           SPRINTF_FIXED(fetch,
                     "fetch " FORMAT_LEN " in \"%s\"",
                     qi.fetch_size, SC_cursor_name(self));
            qryi = &qi;
@@ -2162,7 +2162,7 @@ inolog("!!! numfield=%d field_type=%u\n", QR_NumResultCols(res), QR_get_field_ty
            qi.result_in = NULL;
            qi.cursor = SC_cursor_name(self);
            qi.cache_size = qi.row_size = ci->drivers.fetch_max;
-           snprintf(fetch, sizeof(fetch), "fetch " FORMAT_LEN " in \"%s\"", qi.fetch_size, SC_cursor_name(self));
+           SPRINTF_FIXED(fetch, "fetch " FORMAT_LEN " in \"%s\"", qi.fetch_size, SC_cursor_name(self));
            res = CC_send_query(conn, fetch, &qi, qflag, SC_get_ancestor(self));
            if (NULL != res)
                SC_set_Result(self, res);
@@ -2371,7 +2371,7 @@ RequestStart(StatementClass *stmt, ConnectionClass *conn, const char *func)
    {
        char    emsg[128];
 
-       snprintf(emsg, sizeof(emsg), "internal savepoint error in %s", func);
+       SPRINTF_FIXED(emsg, "internal savepoint error in %s", func);
        SC_set_error_if_not_set(stmt, STMT_INTERNAL_ERROR, emsg, func);
        return FALSE;
    }