pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ludek Finstrle <ludek.finstrle@pzkagis.cz>
To: pgsql-odbc@postgresql.org
Subject: schema and win1250 support + misc
Date: Fri, 9 Jan 2004 16:14:44 +0100
Message-ID: <20040109151444.GA12471@soptik.pzkagis.cz> (raw)

Hello,

  I need schema support in odbc driver (it means change schema when
connecting) more user friendly. So I attach patch for US only.

Second patch contains support for win1250 encoding and
one (I think) bug fix. It's in pgtypes.c in getCharColumnSize.
This function call SC_get_Curres which can return NULL and
getCharColumnSize doesn't handle it.

Comments are welcome

Luf

P.S. I use diff -iwaru <orig> <new> to create *.diff. I create
     diffs againist CVS snapshoted today.

Attachments: download all (2 files, .tar.gz)

odbc-schema.diff (text/plain, 7.0K) download diff -iwaru PgSQL.orig/ODBC/connection.c PgSQL/ODBC/connection.c --- PgSQL.orig/ODBC/connection.c 2004-01-09 14:22:11.000000000 +0100 +++ PgSQL/ODBC/connection.c 2004-01-09 15:16:10.976734400 +0100 @@ -728,7 +728,7 @@ return 0; } - mylog("CC_connect(): DSN = '%s', server = '%s', port = '%s', database = '%s', username = '%s', password='%s'\n", ci->dsn, ci->server, ci->port, ci->database, ci->username, ci->password ? "xxxxx" : ""); + mylog("CC_connect(): DSN = '%s', server = '%s', port = '%s', database = '%s', schema = '%s', username = '%s', password='%s'\n", ci->dsn, ci->server, ci->port, ci->database, ci->schema, ci->username, ci->password ? "xxxxx" : ""); another_version_retry: @@ -1882,6 +1882,7 @@ char status = TRUE; char *cs, *ptr; + char schema[MEDIUM_REGISTRY_LEN+22]; #ifdef HAVE_STRTOK_R char *last; #endif /* HAVE_STRTOK_R */ @@ -1942,6 +1943,18 @@ } + /* schema (applicable since 7.3) */ + if (self->schema_support && ci->schema && strlen(ci->schema)) + { + snprintf(schema, sizeof(schema), "set search_path to '%s'", ci->schema); + result = PGAPI_ExecDirect(hstmt, schema, SQL_NTS, 0); + if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) + status = FALSE; + + mylog("%s: result %d, status %d from set search_path\n", func, result, status); + + } + /* Global settings */ if (ci->drivers.conn_settings[0] != '\0') { diff -iwaru PgSQL.orig/ODBC/connection.h PgSQL/ODBC/connection.h --- PgSQL.orig/ODBC/connection.h 2004-01-09 14:22:11.000000000 +0100 +++ PgSQL/ODBC/connection.h 2004-01-09 15:16:56.572297600 +0100 @@ -234,6 +234,7 @@ char drivername[MEDIUM_REGISTRY_LEN]; char server[MEDIUM_REGISTRY_LEN]; char database[MEDIUM_REGISTRY_LEN]; + char schema[MEDIUM_REGISTRY_LEN]; char username[MEDIUM_REGISTRY_LEN]; char password[MEDIUM_REGISTRY_LEN]; char conn_settings[LARGE_REGISTRY_LEN]; diff -iwaru PgSQL.orig/ODBC/dlg_specific.c PgSQL/ODBC/dlg_specific.c --- PgSQL.orig/ODBC/dlg_specific.c 2004-01-09 14:22:11.000000000 +0100 +++ PgSQL/ODBC/dlg_specific.c 2004-01-09 15:22:24.003120000 +0100 @@ -271,6 +271,9 @@ else if (stricmp(attribute, "driver") == 0) strcpy(ci->drivername, value); + else if (stricmp(attribute, INI_SCHEMA) == 0) + strcpy(ci->schema, value); + else if (stricmp(attribute, INI_DATABASE) == 0) strcpy(ci->database, value); @@ -328,7 +331,7 @@ else if (stricmp(attribute, "CX") == 0) unfoldCXAttribute(ci, value); - mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',onlyread='%s',protocol='%s',conn_settings='%s',disallow_premature=%d)\n", ci->dsn, ci->server, ci->database, ci->username, ci->password ? "xxxxx" : "", ci->port, ci->onlyread, ci->protocol, ci->conn_settings, ci->disallow_premature); + mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',schema='%s',user='%s',passwd='%s',port='%s',onlyread='%s',protocol='%s',conn_settings='%s',disallow_premature=%d)\n", ci->dsn, ci->server, ci->database, ci->schema, ci->username, ci->password ? "xxxxx" : "", ci->port, ci->onlyread, ci->protocol, ci->conn_settings, ci->disallow_premature); } void @@ -483,6 +486,9 @@ if (ci->database[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_DATABASE, "", ci->database, sizeof(ci->database), ODBC_INI); + if (ci->schema[0] == '\0' || overwrite) + SQLGetPrivateProfileString(DSN, INI_SCHEMA, "", ci->schema, sizeof(ci->schema), ODBC_INI); + if (ci->username[0] == '\0' || overwrite) SQLGetPrivateProfileString(DSN, INI_USER, "", ci->username, sizeof(ci->username), ODBC_INI); @@ -581,11 +587,12 @@ /* Allow override of odbcinst.ini parameters here */ getCommonDefaults(DSN, ODBC_INI, ci); - qlog("DSN info: DSN='%s',server='%s',port='%s',dbase='%s',user='%s',passwd='%s'\n", + qlog("DSN info: DSN='%s',server='%s',port='%s',dbase='%s',schema='%s',user='%s',passwd='%s'\n", DSN, ci->server, ci->port, ci->database, + ci->schema, ci->username, ci->password ? "xxxxx" : ""); qlog(" onlyread='%s',protocol='%s',showoid='%s',fakeoidindex='%s',showsystable='%s'\n", @@ -716,6 +723,11 @@ ODBC_INI); SQLWritePrivateProfileString(DSN, + INI_SCHEMA, + ci->schema, + ODBC_INI); + + SQLWritePrivateProfileString(DSN, INI_SERVER, ci->server, ODBC_INI); diff -iwaru PgSQL.orig/ODBC/dlg_specific.h PgSQL/ODBC/dlg_specific.h --- PgSQL.orig/ODBC/dlg_specific.h 2003-08-27 13:17:53.000000000 +0200 +++ PgSQL/ODBC/dlg_specific.h 2004-01-09 15:23:10.079374400 +0100 @@ -51,6 +51,7 @@ #define INI_PORT "Port" /* Port on which the * Postmaster is listening */ #define INI_DATABASE "Database" /* Database Name */ +#define INI_SCHEMA "Schema" /* Schema Name */ #define INI_USER "Username" /* Default User Name */ #define INI_PASSWORD "Password" /* Default Password */ #define INI_DEBUG "Debug" /* Debug flag */ diff -iwaru PgSQL.orig/ODBC/dlg_wingui.c PgSQL/ODBC/dlg_wingui.c --- PgSQL.orig/ODBC/dlg_wingui.c 2003-08-27 13:17:53.000000000 +0200 +++ PgSQL/ODBC/dlg_wingui.c 2004-01-09 15:24:29.663811200 +0100 @@ -56,6 +56,7 @@ /**}**/ SetDlgItemText(hdlg, IDC_DATABASE, ci->database); + SetDlgItemText(hdlg, IDC_SCHEMA, ci->schema); SetDlgItemText(hdlg, IDC_SERVER, ci->server); SetDlgItemText(hdlg, IDC_USER, ci->username); SetDlgItemText(hdlg, IDC_PASSWORD, ci->password); @@ -69,6 +70,7 @@ GetDlgItemText(hdlg, IDC_DESC, ci->desc, sizeof(ci->desc)); GetDlgItemText(hdlg, IDC_DATABASE, ci->database, sizeof(ci->database)); + GetDlgItemText(hdlg, IDC_SCHEMA, ci->schema, sizeof(ci->schema)); GetDlgItemText(hdlg, IDC_SERVER, ci->server, sizeof(ci->server)); GetDlgItemText(hdlg, IDC_USER, ci->username, sizeof(ci->username)); GetDlgItemText(hdlg, IDC_PASSWORD, ci->password, sizeof(ci->password)); diff -iwaru PgSQL.orig/ODBC/psqlodbc.rc PgSQL/ODBC/psqlodbc.rc --- PgSQL.orig/ODBC/psqlodbc.rc 2003-05-14 04:32:32.000000000 +0200 +++ PgSQL/ODBC/psqlodbc.rc 2004-01-09 15:31:48.004113600 +0100 @@ -384,6 +382,8 @@ EDITTEXT IDC_DESC,192,24,107,12,ES_AUTOHSCROLL RTEXT "Data&base",IDC_STATIC,16,40,38,12,NOT WS_GROUP EDITTEXT IDC_DATABASE,57,39,72,12,ES_AUTOHSCROLL + RTEXT "Sc&hema",IDC_STATIC,151,40,38,12,NOT WS_GROUP + EDITTEXT IDC_SCHEMA,192,39,72,12,ES_AUTOHSCROLL RTEXT "&Server",IDC_STATIC,26,55,29,12,NOT WS_GROUP EDITTEXT IDC_SERVER,57,54,72,12,ES_AUTOHSCROLL RTEXT "&Port",IDC_STATIC,168,56,22,12 diff -iwaru PgSQL.orig/ODBC/resource.h PgSQL/ODBC/resource.h --- PgSQL.orig/ODBC/resource.h 2003-05-12 18:44:08.000000000 +0200 +++ PgSQL/ODBC/resource.h 2004-01-09 15:31:47.994099200 +0100 @@ -21,6 +21,7 @@ #define IDC_DESC 404 #define IDC_SERVER 407 #define IDC_DATABASE 408 +#define IDC_SCHEMA 409 #define DLG_CONFIG 1001 #define IDC_PORT 1002 #define DLG_DRIVER_CHANGE 1002
odbc-misc.diff (text/plain, 786B) download diff -iwaru PgSQL.orig/ODBC/multibyte.c PgSQL/ODBC/multibyte.c --- PgSQL.orig/ODBC/multibyte.c 2003-12-09 11:01:38.000000000 +0100 +++ PgSQL/ODBC/multibyte.c 2004-01-09 15:50:10.459366400 +0100 @@ -397,6 +397,9 @@ case 950: wenc = "BIG5"; break; + case 1250: + wenc = "WIN1250"; + break; case 1252: if (PG_VERSION_GE(self, 7.2)) wenc = "latin9"; diff -iwaru PgSQL.orig/ODBC/pgtypes.c PgSQL/ODBC/pgtypes.c --- PgSQL.orig/ODBC/pgtypes.c 2004-01-09 14:22:11.000000000 +0100 +++ PgSQL/ODBC/pgtypes.c 2004-01-09 15:54:24.104089600 +0100 @@ -704,7 +704,8 @@ if (col < 0) return maxsize; - result = SC_get_Curres(stmt); + if (!(result = SC_get_Curres(stmt))) + return maxsize; /* * Manual Result Sets -- use assigned column width (i.e., from

view thread (2+ messages)  latest in thread

Message-ID: <20040109151444.GA12471@soptik.pzkagis.cz>
Permalink:  ../20040109151444.GA12471@soptik.pzkagis.cz/
Also on:    postgresql.org/message-id/20040109151444.GA12471@soptik.pzkagis.cz

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: ludek.finstrle@pzkagis.cz
  Subject: Re: schema and win1250 support + misc
  In-Reply-To: <20040109151444.GA12471@soptik.pzkagis.cz>
  References: <20040109151444.GA12471@soptik.pzkagis.cz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox