Browse Source

Fix problem in the previous commit: use ntohl() instead of ntohs() when
converting int4 and cast result to int32_t not int16_t.

Maxim Sobolev 17 years ago
parent
commit
6b51c9e626
1 changed files with 2 additions and 2 deletions
  1. 2 2
      modules/db_postgres/pg_fld.c

+ 2 - 2
modules/db_postgres/pg_fld.c

@@ -627,7 +627,7 @@ static inline int pg_int4_2_db_cstr(db_fld_t* fld, char* val, int len)
 	struct pg_fld* pfld = DB_GET_PAYLOAD(fld);
 	struct pg_fld* pfld = DB_GET_PAYLOAD(fld);
 	int size, v;
 	int size, v;
 
 
-	v = (int16_t)ntohs(*((int32_t*)val));
+	v = (int32_t)ntohl(*((int32_t*)val));
 
 
     size = snprintf(pfld->buf, INT2STR_MAX_LEN, "%-d", v);
     size = snprintf(pfld->buf, INT2STR_MAX_LEN, "%-d", v);
     if (len < 0 || size >= INT2STR_MAX_LEN) {
     if (len < 0 || size >= INT2STR_MAX_LEN) {
@@ -664,7 +664,7 @@ static inline int pg_int4_2_db_str(db_fld_t* fld, char* val, int len)
 	struct pg_fld* pfld = DB_GET_PAYLOAD(fld);
 	struct pg_fld* pfld = DB_GET_PAYLOAD(fld);
 	int size, v;
 	int size, v;
 
 
-	v = (int16_t)ntohs(*((int32_t*)val));
+	v = (int32_t)ntohl(*((int32_t*)val));
 
 
     size = snprintf(pfld->buf, INT2STR_MAX_LEN, "%-d", v);
     size = snprintf(pfld->buf, INT2STR_MAX_LEN, "%-d", v);
     if (size < 0 || size >= INT2STR_MAX_LEN) {
     if (size < 0 || size >= INT2STR_MAX_LEN) {