Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit39dc8ff

Browse files
author
Hiroshi Inoue
committed
1) Avoid an overflow of connection string for Access(Microsoft Jet).
2) Change to retry lower version in case of "Unsupported frontendprocotol".
1 parent6f33c17 commit39dc8ff

File tree

8 files changed

+126
-54
lines changed

8 files changed

+126
-54
lines changed

‎src/interfaces/odbc/connection.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,10 @@ CC_Constructor()
252252
rv->transact_status=CONN_IN_AUTOCOMMIT;/* autocommit by default */
253253

254254
memset(&rv->connInfo,0,sizeof(ConnInfo));
255-
memcpy(&(rv->connInfo.drivers),&globals,sizeof(globals));
255+
#ifdefDRIVER_CURSOR_IMPLEMENT
256+
rv->connInfo.updatable_cursors=1;
257+
#endif/* DRIVER_CURSOR_IMPLEMENT */
258+
memcpy(&(rv->connInfo.drivers),&globals,sizeof(globals));
256259
rv->sock=SOCK_Constructor(rv);
257260
if (!rv->sock)
258261
returnNULL;
@@ -278,6 +281,7 @@ memcpy(&(rv->connInfo.drivers), &globals, sizeof(globals));
278281
rv->pg_version_number=.0;
279282
rv->pg_version_major=0;
280283
rv->pg_version_minor=0;
284+
rv->ms_jet=0;
281285
#ifdefMULTIBYTE
282286
rv->client_encoding=NULL;
283287
rv->server_encoding=NULL;
@@ -586,6 +590,7 @@ CC_connect(ConnectionClass *self, char do_password)
586590

587591
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);
588592

593+
another_version_retry:
589594
/*
590595
* If the socket was closed for some reason (like a SQLDisconnect,
591596
* but no SQLFreeConnect then create a socket now.
@@ -690,6 +695,18 @@ CC_connect(ConnectionClass *self, char do_password)
690695
self->errornumber=CONN_INVALID_AUTHENTICATION;
691696
self->errormsg=msgbuffer;
692697
qlog("ERROR from backend during authentication: '%s'\n",self->errormsg);
698+
if (strncmp(msgbuffer,"Unsupported frontend protocol",29)==0)
699+
{/* retry older version */
700+
if (PROTOCOL_63(ci))
701+
strcpy(ci->protocol,PG62);
702+
else
703+
strcpy(ci->protocol,PG63);
704+
SOCK_Destructor(sock);
705+
self->sock= (SocketClass*)0;
706+
CC_initialize_pg_version(self);
707+
gotoanother_version_retry;
708+
}
709+
693710
return0;
694711
case'R':
695712

‎src/interfaces/odbc/connection.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ typedef struct
160160
chartranslation_option[SMALL_REGISTRY_LEN];
161161
charfocus_password;
162162
chardisallow_premature;
163+
charupdatable_cursors;
163164
GLOBAL_VALUESdrivers;/* moved from driver's option */
164165
}ConnInfo;
165166

@@ -274,6 +275,7 @@ struct ConnectionClass_
274275
floatpg_version_number;
275276
Int2pg_version_major;
276277
Int2pg_version_minor;
278+
charms_jet;
277279
#ifdefMULTIBYTE
278280
char*client_encoding;
279281
char*server_encoding;

‎src/interfaces/odbc/dlg_specific.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len)
510510
chargot_dsn= (ci->dsn[0]!='\0');
511511
charencoded_conn_settings[LARGE_REGISTRY_LEN];
512512
UWORDhlen;
513+
BOOLabbrev= (len <=400);
513514

514515
/* fundamental info */
515516
sprintf(connect_string,"%s=%s;DATABASE=%s;SERVER=%s;PORT=%s;UID=%s;PWD=%s",
@@ -524,8 +525,9 @@ makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len)
524525
encode(ci->conn_settings,encoded_conn_settings);
525526

526527
/* extra info */
527-
hlen=strlen(connect_string),
528-
sprintf(&connect_string[hlen],
528+
hlen=strlen(connect_string);
529+
if (!abbrev)
530+
sprintf(&connect_string[hlen],
529531
";READONLY=%s;PROTOCOL=%s;FAKEOIDINDEX=%s;SHOWOIDCOLUMN=%s;ROWVERSIONING=%s;SHOWSYSTEMTABLES=%s;CONNSETTINGS=%s;FETCH=%d;SOCKET=%d;UNKNOWNSIZES=%d;MAXVARCHARSIZE=%d;MAXLONGVARCHARSIZE=%d;DEBUG=%d;COMMLOG=%d;OPTIMIZER=%d;KSQO=%d;USEDECLAREFETCH=%d;TEXTASLONGVARCHAR=%d;UNKNOWNSASLONGVARCHAR=%d;BOOLSASCHAR=%d;PARSE=%d;CANCELASFREESTMT=%d;EXTRASYSTABLEPREFIXES=%s",
530532
ci->onlyread,
531533
ci->protocol,
@@ -551,7 +553,7 @@ makeConnectString(char *connect_string, const ConnInfo *ci, UWORD len)
551553
ci->drivers.cancel_as_freestmt,
552554
ci->drivers.extra_systable_prefixes);
553555
/* Abbrebiation is needed ? */
554-
if (strlen(connect_string) >=len)
556+
if (abbrev||strlen(connect_string) >=len)
555557
sprintf(&connect_string[hlen],
556558
";A0=%s;A1=%s;A2=%s;A3=%s;A4=%s;A5=%s;A6=%s;A7=%d;A8=%d;A9=%d;B0=%d;B1=%d;B2=%d;B3=%d;B4=%d;B5=%d;B6=%d;B7=%d;B8=%d;B9=%d;C0=%d;C1=%d;C2=%s",
557559
ci->onlyread,
@@ -630,7 +632,10 @@ copyAttributes(ConnInfo *ci, const char *attribute, const char *value)
630632
elseif (stricmp(attribute,INI_DISALLOWPREMATURE)==0||stricmp(attribute,"C3")==0)
631633
{
632634
ci->disallow_premature=atoi(value);
633-
/* strcpy(ci->conn_settings, value); */
635+
}
636+
elseif (stricmp(attribute,INI_UPDATABLECURSORS)==0||stricmp(attribute,"C4")==0)
637+
{
638+
ci->updatable_cursors=atoi(value);
634639
}
635640

636641
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,ci->port,ci->onlyread,ci->protocol,ci->conn_settings,ci->disallow_premature);
@@ -803,6 +808,12 @@ getDSNinfo(ConnInfo *ci, char overwrite)
803808
ci->disallow_premature=atoi(temp);
804809
}
805810

811+
if (ci->updatable_cursors==0||overwrite)
812+
{
813+
SQLGetPrivateProfileString(DSN,INI_UPDATABLECURSORS,"",temp,sizeof(temp),ODBC_INI);
814+
ci->updatable_cursors=atoi(temp);
815+
}
816+
806817
/* Allow override of odbcinst.ini parameters here */
807818
getCommonDefaults(DSN,ODBC_INI,ci);
808819

@@ -916,6 +927,11 @@ writeDSNinfo(const ConnInfo *ci)
916927
INI_DISALLOWPREMATURE,
917928
temp,
918929
ODBC_INI);
930+
sprintf(temp,"%d",ci->updatable_cursors);
931+
SQLWritePrivateProfileString(DSN,
932+
INI_UPDATABLECURSORS,
933+
temp,
934+
ODBC_INI);
919935
}
920936

921937

‎src/interfaces/odbc/dlg_specific.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
#defineINI_TRANSLATIONDLL"TranslationDLL"
9797
#defineINI_TRANSLATIONOPTION"TranslationOption"
9898
#defineINI_DISALLOWPREMATURE"DisallowPremature"
99+
#defineINI_UPDATABLECURSORS"UpdatableCursors"
99100

100101

101102
/*Connection Defaults */

‎src/interfaces/odbc/drvconn.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*-------
2-
* Module:drvconn.c
2+
Module:drvconn.c
33
*
44
* Description:This module contains only routines related to
55
*implementing SQLDriverConnect.
@@ -88,6 +88,7 @@ PGAPI_DriverConnect(
8888
intretval;
8989
charpassword_required= FALSE;
9090
intlen=0;
91+
SWORDlenStrout;
9192

9293

9394
mylog("%s: entering...\n",func);
@@ -211,7 +212,10 @@ PGAPI_DriverConnect(
211212
*/
212213
result=SQL_SUCCESS;
213214

214-
makeConnectString(connStrOut,ci,cbConnStrOutMax);
215+
lenStrout=cbConnStrOutMax;
216+
if (conn->ms_jet&&lenStrout>255)
217+
lenStrout=255;
218+
makeConnectString(connStrOut,ci,lenStrout);
215219
len=strlen(connStrOut);
216220

217221
if (szConnStrOut)

‎src/interfaces/odbc/info.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,17 @@ PGAPI_GetInfo(
166166
caseSQL_CURSOR_COMMIT_BEHAVIOR:/* ODBC 1.0 */
167167
len=2;
168168
value=SQL_CB_CLOSE;
169-
#ifdefDRIVER_CURSOR_IMPLEMENT
170-
if (!ci->drivers.use_declarefetch)
171-
value=SQL_CB_PRESERVE;
172-
#endif/* DRIVER_CURSOR_IMPLEMENT */
169+
if (ci->updatable_cursors)
170+
if (!ci->drivers.use_declarefetch)
171+
value=SQL_CB_PRESERVE;
173172
break;
174173

175174
caseSQL_CURSOR_ROLLBACK_BEHAVIOR:/* ODBC 1.0 */
176175
len=2;
177176
value=SQL_CB_CLOSE;
178-
#ifdefDRIVER_CURSOR_IMPLEMENT
179-
if (!ci->drivers.use_declarefetch)
180-
value=SQL_CB_PRESERVE;
181-
#endif/* DRIVER_CURSOR_IMPLEMENT */
177+
if (ci->updatable_cursors)
178+
if (!ci->drivers.use_declarefetch)
179+
value=SQL_CB_PRESERVE;
182180
break;
183181

184182
caseSQL_DATA_SOURCE_NAME:/* ODBC 1.0 */
@@ -235,7 +233,7 @@ PGAPI_GetInfo(
235233
if (dver[0])
236234
{
237235
intmajor,minor;
238-
mylog("REIGISTRY_ODBC_VER = %s\n",dver)
236+
mylog("REGISTRY_ODBC_VER = %s\n",dver)
239237
;
240238
if (sscanf(dver,"%x.%x",&major,&minor) >=2)
241239
{
@@ -524,6 +522,8 @@ PGAPI_GetInfo(
524522
caseSQL_POS_OPERATIONS:/* ODBC 2.0 */
525523
len=4;
526524
value=ci->drivers.lie ? (SQL_POS_POSITION |SQL_POS_REFRESH |SQL_POS_UPDATE |SQL_POS_DELETE |SQL_POS_ADD) : (SQL_POS_POSITION |SQL_POS_REFRESH);
525+
if (ci->updatable_cursors)
526+
value |= (SQL_POS_UPDATE |SQL_POS_DELETE |SQL_POS_ADD);
527527
break;
528528

529529
caseSQL_POSITIONED_STATEMENTS:/* ODBC 2.0 */
@@ -571,15 +571,18 @@ PGAPI_GetInfo(
571571
* Driver doesn't support keyset-driven or mixed cursors, so
572572
* not much point in saying row updates are supported
573573
*/
574-
p=ci->drivers.lie ?"Y" :"N";
574+
p=(ci->drivers.lie||ci->updatable_cursors) ?"Y" :"N";
575575
break;
576576

577577
caseSQL_SCROLL_CONCURRENCY:/* ODBC 1.0 */
578578
len=4;
579579
value=ci->drivers.lie ? (SQL_SCCO_READ_ONLY |
580580
SQL_SCCO_LOCK |
581581
SQL_SCCO_OPT_ROWVER |
582-
SQL_SCCO_OPT_VALUES) : (SQL_SCCO_READ_ONLY);
582+
SQL_SCCO_OPT_VALUES) :
583+
(SQL_SCCO_READ_ONLY);
584+
if (ci->updatable_cursors)
585+
value |=SQL_SCCO_OPT_ROWVER;
583586
break;
584587

585588
caseSQL_SCROLL_OPTIONS:/* ODBC 1.0 */
@@ -588,7 +591,10 @@ PGAPI_GetInfo(
588591
SQL_SO_STATIC |
589592
SQL_SO_KEYSET_DRIVEN |
590593
SQL_SO_DYNAMIC |
591-
SQL_SO_MIXED) : (ci->drivers.use_declarefetch ?SQL_SO_FORWARD_ONLY : (SQL_SO_FORWARD_ONLY |SQL_SO_STATIC));
594+
SQL_SO_MIXED)
595+
: (ci->drivers.use_declarefetch ?SQL_SO_FORWARD_ONLY : (SQL_SO_FORWARD_ONLY |SQL_SO_STATIC));
596+
if (ci->updatable_cursors)
597+
value |=0;/* SQL_SO_KEYSET_DRIVEN in the furure */
592598
break;
593599

594600
caseSQL_SEARCH_PATTERN_ESCAPE:/* ODBC 1.0 */
@@ -606,6 +612,8 @@ PGAPI_GetInfo(
606612
caseSQL_STATIC_SENSITIVITY:/* ODBC 2.0 */
607613
len=4;
608614
value=ci->drivers.lie ? (SQL_SS_ADDITIONS |SQL_SS_DELETIONS |SQL_SS_UPDATES) :0;
615+
if (ci->updatable_cursors)
616+
value |= (SQL_SS_ADDITIONS |SQL_SS_DELETIONS |SQL_SS_UPDATES);
609617
break;
610618

611619
caseSQL_STRING_FUNCTIONS:/* ODBC 1.0 */

‎src/interfaces/odbc/options.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,15 @@ PGAPI_SetConnectOption(
412412
conn->errormsg="Unknown connect option (Set)";
413413
conn->errornumber=CONN_UNSUPPORTED_OPTION;
414414
sprintf(option,"fOption=%d, vParam=%ld",fOption,vParam);
415+
if (fOption==30002&&vParam)
416+
{
417+
if (strcmp((char*)vParam,"Microsoft Jet")==0)
418+
{
419+
conn->errornumber=0;
420+
conn->ms_jet=1;
421+
returnSQL_SUCCESS;
422+
}
423+
}
415424
CC_log_error(func,option,conn);
416425
returnSQL_ERROR;
417426
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp