? Release ? widetypes.diff ? installer/psqlodbc.msi ? installer/psqlodbc.msm ? installer/psqlodbc.wixobj ? installer/psqlodbcm.wixobj ? installer/Thumbs.db Index: connection.c =================================================================== RCS file: /usr/local/cvsroot/psqlodbc/psqlodbc/connection.c,v retrieving revision 1.108 diff -c -r1.108 connection.c *** connection.c 31 Aug 2005 07:31:44 -0000 1.108 --- connection.c 31 Aug 2005 11:28:04 -0000 *************** *** 2686,2691 **** --- 2686,2719 ---- CC_lookup_lo(self); /* a hack to get the oid of our large object oid type */ + /* + * Set/unset the use Unicode internal flag if required. + * If the database is Unicode, then we offer full Unicode support, + * otherwise, fall back to ANSI. + * This doesn't actually enable/disable Unicode support - it just + * turns on or off the SQL_C_Wxxx type mappings. + */ + if (!self->server_encoding) + { + QResultClass *res; + if (res = CC_send_query(self, "select getdatabaseencoding()", NULL, CLEAR_RESULT_ON_ABORT), res) + { + if (QR_get_num_total_tuples(res) > 0) + self->server_encoding = strdup(QR_get_value_backend_row(res, 0, 0)); + QR_Destructor(res); + } + if (strcmp(self->server_encoding, "UNICODE") == 0) + { + self->report_wide_types = 1; + mylog("Server encoding: %s. Wide types enabled.\n", self->server_encoding); + } + else + { + self->report_wide_types = 0; + mylog("Server encoding: %s. Wide types disabled.\n", self->server_encoding); + } + } + /* * Multibyte handling is available ? */ *************** *** 2695,2701 **** if (CC_get_errornumber(self) != 0) return 0; ! if (self->unicode) { if (!self->client_encoding || stricmp(self->client_encoding, "UNICODE")) --- 2723,2729 ---- if (CC_get_errornumber(self) != 0) return 0; ! if (self->unicode && self->report_wide_types) { if (!self->client_encoding || stricmp(self->client_encoding, "UNICODE")) *************** *** 3138,3144 **** CC_set_error(self,CONNECTION_COULD_NOT_ESTABLISH,PQerrorMessage(self->pgconn)); mylog("could not establish connection to the database %s \n",PQerrorMessage(self->pgconn)); PQfinish(self->pgconn); ! self->pgconn = NULL; free(conninfo); return 0; } --- 3166,3172 ---- CC_set_error(self,CONNECTION_COULD_NOT_ESTABLISH,PQerrorMessage(self->pgconn)); mylog("could not establish connection to the database %s \n",PQerrorMessage(self->pgconn)); PQfinish(self->pgconn); ! self->pgconn = NULL; free(conninfo); return 0; } Index: libpqconnection.h =================================================================== RCS file: /usr/local/cvsroot/psqlodbc/psqlodbc/libpqconnection.h,v retrieving revision 1.4 diff -c -r1.4 libpqconnection.h *** libpqconnection.h 30 Aug 2005 09:19:50 -0000 1.4 --- libpqconnection.h 31 Aug 2005 11:28:07 -0000 *************** *** 333,338 **** --- 333,339 ---- Int2 pg_version_minor; char ms_jet; char unicode; + char report_wide_types; char result_uncommitted; char schema_support; char *client_encoding; Index: pgtypes.c =================================================================== RCS file: /usr/local/cvsroot/psqlodbc/psqlodbc/pgtypes.c,v retrieving revision 1.70 diff -c -r1.70 pgtypes.c *** pgtypes.c 3 Aug 2005 08:09:33 -0000 1.70 --- pgtypes.c 31 Aug 2005 11:28:15 -0000 *************** *** 250,268 **** case PG_TYPE_BPCHAR: if (col >= 0 && getCharColumnSize(stmt, type, col, UNKNOWNS_AS_MAX) > ci->drivers.max_varchar_size) ! return conn->unicode ? SQL_WLONGVARCHAR : SQL_LONGVARCHAR; ! return conn->unicode ? SQL_WCHAR : SQL_CHAR; case PG_TYPE_VARCHAR: if (col >= 0 && getCharColumnSize(stmt, type, col, UNKNOWNS_AS_MAX) > ci->drivers.max_varchar_size) ! return conn->unicode ? SQL_WLONGVARCHAR : SQL_LONGVARCHAR; ! return conn->unicode ? SQL_WVARCHAR : SQL_VARCHAR; case PG_TYPE_TEXT: return ci->drivers.text_as_longvarchar ? ! (conn->unicode ? SQL_WLONGVARCHAR : SQL_LONGVARCHAR) : ! (conn->unicode ? SQL_WVARCHAR : SQL_VARCHAR); case PG_TYPE_BYTEA: if (ci->bytea_as_longvarbinary) --- 250,268 ---- case PG_TYPE_BPCHAR: if (col >= 0 && getCharColumnSize(stmt, type, col, UNKNOWNS_AS_MAX) > ci->drivers.max_varchar_size) ! return (conn->unicode && conn->report_wide_types) ? SQL_WLONGVARCHAR : SQL_LONGVARCHAR; ! return (conn->unicode && conn->report_wide_types) ? SQL_WCHAR : SQL_CHAR; case PG_TYPE_VARCHAR: if (col >= 0 && getCharColumnSize(stmt, type, col, UNKNOWNS_AS_MAX) > ci->drivers.max_varchar_size) ! return (conn->unicode && conn->report_wide_types) ? SQL_WLONGVARCHAR : SQL_LONGVARCHAR; ! return (conn->unicode && conn->report_wide_types) ? SQL_WVARCHAR : SQL_VARCHAR; case PG_TYPE_TEXT: return ci->drivers.text_as_longvarchar ? ! ((conn->unicode && conn->report_wide_types) ? SQL_WLONGVARCHAR : SQL_LONGVARCHAR) : ! ((conn->unicode && conn->report_wide_types) ? SQL_WVARCHAR : SQL_VARCHAR); case PG_TYPE_BYTEA: if (ci->bytea_as_longvarbinary) *************** *** 416,422 **** case PG_TYPE_BPCHAR: case PG_TYPE_VARCHAR: case PG_TYPE_TEXT: ! if (conn->unicode && ! conn->ms_jet && ! stmt->manual_result) return SQL_C_WCHAR; return SQL_C_CHAR; --- 416,422 ---- case PG_TYPE_BPCHAR: case PG_TYPE_VARCHAR: case PG_TYPE_TEXT: ! if (conn->unicode && conn->report_wide_types && ! conn->ms_jet && ! stmt->manual_result) return SQL_C_WCHAR; return SQL_C_CHAR; *************** *** 977,984 **** { int coef = 1; Int4 prec = pgtype_column_size(stmt, type, col, handle_unknown_size_as), maxvarc; ! if (conn->unicode) ! return prec * 2; /* after 7.2 */ if (PG_VERSION_GE(conn, 7.2)) coef = 3; --- 977,984 ---- { int coef = 1; Int4 prec = pgtype_column_size(stmt, type, col, handle_unknown_size_as), maxvarc; ! if (conn->unicode && conn->report_wide_types) ! return prec * WCLEN; /* after 7.2 */ if (PG_VERSION_GE(conn, 7.2)) coef = 3; *************** *** 1054,1061 **** { case PG_TYPE_VARCHAR: case PG_TYPE_BPCHAR: ! if (conn->unicode) ! return prec * 2; /* after 7.2 */ if (PG_VERSION_GE(conn, 7.2)) coef = 3; --- 1054,1061 ---- { case PG_TYPE_VARCHAR: case PG_TYPE_BPCHAR: ! if (conn->unicode && conn->report_wide_types) ! return prec * WCLEN; /* after 7.2 */ if (PG_VERSION_GE(conn, 7.2)) coef = 3; *************** *** 1406,1412 **** case SQL_WCHAR: case SQL_WVARCHAR: case SQL_WLONGVARCHAR: ! if (conn->ms_jet || ! conn->unicode) return SQL_C_CHAR; return SQL_C_WCHAR; --- 1406,1412 ---- case SQL_WCHAR: case SQL_WVARCHAR: case SQL_WLONGVARCHAR: ! if (conn->ms_jet || ! conn->unicode || ! conn->report_wide_types) return SQL_C_CHAR; return SQL_C_WCHAR;