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

Commit4ad1b5b

Browse files
author
Hiroshi Inoue
committed
Resolve compile errors on unix.
Rename psqlodbc.def -> psqlodbc_win32.def.Improve internal *declare cursor* handlinga little.Hiroshi Inoue
1 parent02b1a7f commit4ad1b5b

File tree

9 files changed

+121
-56
lines changed

9 files changed

+121
-56
lines changed

‎src/interfaces/odbc/convert.c

Lines changed: 95 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include<string.h>
2222
#include<ctype.h>
2323

24+
#include"psqlodbc.h"
2425
#ifdefMULTIBYTE
2526
#include"multibyte.h"
2627
#endif
@@ -938,6 +939,26 @@ into_table_from(const char *stmt)
938939
returnisspace((unsignedchar)stmt[4]);
939940
}
940941

942+
/*----------
943+
*Check if the statement is
944+
*SELECT ... FOR UPDATE .....
945+
*This isn't really a strict check but ...
946+
*----------
947+
*/
948+
staticBOOL
949+
table_for_update(constchar*stmt,int*endpos)
950+
{
951+
constchar*wstmt=stmt;
952+
while (isspace((unsignedchar)*(++wstmt)));
953+
if (!*wstmt)
954+
return FALSE;
955+
if (strnicmp(wstmt,"update",6))
956+
return FALSE;
957+
wstmt+=6;
958+
*endpos=wstmt-stmt;
959+
return !wstmt[0]||isspace((unsignedchar)wstmt[0]);
960+
}
961+
941962
/*
942963
*This function inserts parameters into an SQL statements.
943964
*It will also modify a SELECT statement for use with declare/fetch cursors.
@@ -968,14 +989,17 @@ copy_statement_with_parameters(StatementClass *stmt)
968989
Oidlobj_oid;
969990
intlobj_fd,
970991
retval;
971-
BOOLcheck_select_into= FALSE;/*select into check */
992+
BOOLcheck_cursor_ok= FALSE;/*check cursor restriction */
972993
BOOLproc_no_param= TRUE;
973-
unsignedintdeclare_pos;
994+
unsignedintdeclare_pos=0;
974995
ConnectionClass*conn=SC_get_conn(stmt);
975996
ConnInfo*ci=&(conn->connInfo);
976-
BOOLprepare_dummy_cursor= FALSE;
997+
BOOLprepare_dummy_cursor= FALSE;
998+
chartoken_save[32];
999+
inttoken_len;
1000+
BOOLprev_token_end;
9771001
#ifdefDRIVER_CURSOR_IMPLEMENT
978-
BOOLins_ctrl= FALSE;
1002+
BOOLsearch_from_pos= FALSE;
9791003
#endif/* DRIVER_CURSOR_IMPLEMENT */
9801004
#ifdefPREPARE_TRIAL
9811005
prepare_dummy_cursor=stmt->pre_executing;
@@ -1012,7 +1036,7 @@ copy_statement_with_parameters(StatementClass *stmt)
10121036
stmt->options.scroll_concurrency=SQL_CONCUR_READ_ONLY;
10131037
elseif (!stmt->ti||stmt->ntab!=1)
10141038
stmt->options.scroll_concurrency=SQL_CONCUR_READ_ONLY;
1015-
elseins_ctrl= TRUE;
1039+
elsesearch_from_pos= TRUE;
10161040
}
10171041
#endif/* DRIVER_CURSOR_IMPLEMENT */
10181042

@@ -1021,7 +1045,10 @@ copy_statement_with_parameters(StatementClass *stmt)
10211045
sprintf(stmt->cursor_name,"SQL_CUR%p",stmt);
10221046
oldstmtlen=strlen(old_statement);
10231047
CVT_INIT(oldstmtlen);
1048+
10241049
stmt->miscinfo=0;
1050+
token_len=0;
1051+
prev_token_end= TRUE;
10251052
/* For selects, prepend a declare cursor to the statement */
10261053
if (stmt->statement_type==STMT_TYPE_SELECT)
10271054
{
@@ -1035,10 +1062,10 @@ copy_statement_with_parameters(StatementClass *stmt)
10351062
}
10361063
elseif (ci->drivers.use_declarefetch)
10371064
SC_set_fetchcursor(stmt);
1038-
sprintf(new_statement,"%s declare %s cursor for ",
1065+
sprintf(new_statement,"%sdeclare %s cursor for ",
10391066
new_statement,stmt->cursor_name);
10401067
npos=strlen(new_statement);
1041-
check_select_into= TRUE;
1068+
check_cursor_ok= TRUE;
10421069
declare_pos=npos;
10431070
}
10441071
}
@@ -1176,28 +1203,68 @@ copy_statement_with_parameters(StatementClass *stmt)
11761203
in_escape= TRUE;
11771204
elseif (oldchar=='\"')
11781205
in_dquote= TRUE;
1179-
elseif (check_select_into&&/* select into check */
1180-
opos>0&&
1181-
isspace((unsignedchar)old_statement[opos-1])&&
1182-
into_table_from(&old_statement[opos]))
1206+
else
11831207
{
1184-
stmt->statement_type=STMT_TYPE_CREATE;
1185-
SC_no_pre_executable(stmt);
1186-
SC_no_fetchcursor(stmt);
1187-
stmt->options.scroll_concurrency=SQL_CONCUR_READ_ONLY;
1188-
memmove(new_statement,new_statement+declare_pos,npos-declare_pos);
1189-
npos-=declare_pos;
1190-
}
1208+
if (isspace(oldchar))
1209+
{
1210+
if (!prev_token_end)
1211+
{
1212+
prev_token_end= TRUE;
1213+
token_save[token_len]='\0';
1214+
if (token_len==4)
1215+
{
1216+
if (check_cursor_ok&&
1217+
into_table_from(&old_statement[opos-token_len]))
1218+
{
1219+
stmt->statement_type=STMT_TYPE_CREATE;
1220+
SC_no_pre_executable(stmt);
1221+
SC_no_fetchcursor(stmt);
1222+
stmt->options.scroll_concurrency=SQL_CONCUR_READ_ONLY;
1223+
memmove(new_statement,new_statement+declare_pos,npos-declare_pos);
1224+
npos-=declare_pos;
1225+
}
11911226
#ifdefDRIVER_CURSOR_IMPLEMENT
1192-
elseif (ins_ctrl&&/* select into check */
1193-
opos>0&&
1194-
isspace((unsignedchar)old_statement[opos-1])&&
1195-
strnicmp(&old_statement[opos],"from",4)==0)
1196-
{
1197-
ins_ctrl= FALSE;
1198-
CVT_APPEND_STR(", CTID, OID ");
1199-
}
1227+
elseif (search_from_pos&&/* where's from clause */
1228+
strnicmp(token_save, "from",4)==0)
1229+
{
1230+
search_from_pos= FALSE;
1231+
npos-=5;
1232+
CVT_APPEND_STR(", CTID, OID from");
1233+
}
12001234
#endif/* DRIVER_CURSOR_IMPLEMENT */
1235+
}
1236+
if (token_len==3)
1237+
{
1238+
intendpos;
1239+
if (check_cursor_ok&&
1240+
strnicmp(token_save,"for",3)==0&&
1241+
table_for_update(&old_statement[opos],&endpos))
1242+
{
1243+
SC_no_fetchcursor(stmt);
1244+
stmt->options.scroll_concurrency=SQL_CONCUR_READ_ONLY;
1245+
if (prepare_dummy_cursor)
1246+
{
1247+
npos-=4;
1248+
opos+=endpos;
1249+
}
1250+
else
1251+
{
1252+
memmove(new_statement,new_statement+declare_pos,npos-declare_pos);
1253+
npos-=declare_pos;
1254+
}
1255+
}
1256+
}
1257+
}
1258+
}
1259+
elseif (prev_token_end)
1260+
{
1261+
prev_token_end= FALSE;
1262+
token_save[0]=oldchar;
1263+
token_len=1;
1264+
}
1265+
else
1266+
token_save[token_len++]=oldchar;
1267+
}
12011268
CVT_APPEND_CHAR(oldchar);
12021269
continue;
12031270
}
@@ -1634,7 +1701,7 @@ copy_statement_with_parameters(StatementClass *stmt)
16341701
}
16351702

16361703
#ifdefDRIVER_CURSOR_IMPLEMENT
1637-
if (ins_ctrl)
1704+
if (search_from_pos)
16381705
stmt->options.scroll_concurrency=SQL_CONCUR_READ_ONLY;
16391706
#endif/* DRIVER_CURSOR_IMPLEMENT */
16401707
#ifdefPREPARE_TRIAL
@@ -2142,7 +2209,7 @@ decode(const char *in, char *out)
21422209
*-------
21432210
*/
21442211
int
2145-
convert_lo(StatementClass*stmt,void*value,Int2fCType,PTRrgbValue,
2212+
convert_lo(StatementClass*stmt,constvoid*value,Int2fCType,PTRrgbValue,
21462213
SDWORDcbValueMax,SDWORD*pcbValue)
21472214
{
21482215
Oidoid;

‎src/interfaces/odbc/convert.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ typedef struct
2929
intss;
3030
}SIMPLE_TIME;
3131

32-
intcopy_and_convert_field_bindinfo(StatementClass*stmt,Int4field_type,constvoid*value,intcol);
33-
intcopy_and_convert_field(StatementClass*stmt,Int4field_type,constvoid*value,Int2fCType,
32+
intcopy_and_convert_field_bindinfo(StatementClass*stmt,Int4field_type,void*value,intcol);
33+
intcopy_and_convert_field(StatementClass*stmt,Int4field_type,void*value,Int2fCType,
3434
PTRrgbValue,SDWORDcbValueMax,SDWORD*pcbValue);
3535

3636
intcopy_statement_with_parameters(StatementClass*stmt);

‎src/interfaces/odbc/execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,11 @@ PGAPI_Cancel(
458458
staticchar*func="PGAPI_Cancel";
459459
StatementClass*stmt= (StatementClass*)hstmt;
460460
RETCODEresult;
461+
ConnInfo*ci;
461462

462463
#ifdefWIN32
463464
HMODULEhmodule;
464465
FARPROCaddr;
465-
ConnInfo*ci;
466466

467467
#endif
468468

‎src/interfaces/odbc/gpps.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@
5151
* ODBCINST_INI
5252
*/
5353
DWORD
54-
GetPrivateProfileString(char*theSection,/* section name */
55-
char*theKey,/* search key name */
56-
char*theDefault,/* default value if not
54+
GetPrivateProfileString(constchar*theSection,/* section name */
55+
constchar*theKey,/* search key name */
56+
constchar*theDefault,/* default value if not
5757
* found */
5858
char*theReturnBuffer,/* return value stored
5959
* here */
6060
size_ttheReturnBufferLength,/* byte length of return
6161
* buffer */
62-
char*theIniFileName)/* pathname of ini file to
62+
constchar*theIniFileName)/* pathname of ini file to
6363
* search */
6464
{
6565
charbuf[MAXPGPATH];
@@ -273,10 +273,10 @@ GetPrivateProfileString(char *theSection,/* section name */
273273

274274

275275
DWORD
276-
WritePrivateProfileString(char*theSection,/* section name */
277-
char*theKey,/* write key name */
278-
char*theBuffer,/* input buffer */
279-
char*theIniFileName)/* pathname of ini file to
276+
WritePrivateProfileString(constchar*theSection,/* section name */
277+
constchar*theKey,/* write key name */
278+
constchar*theBuffer,/* input buffer */
279+
constchar*theIniFileName)/* pathname of ini file to
280280
* write */
281281
{
282282
return0;

‎src/interfaces/odbc/gpps.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@ extern"C"
1717
#endif
1818

1919
DWORD
20-
GetPrivateProfileString(char*theSection,/* section name */
21-
char*theKey,/* search key name */
22-
char*theDefault,/* default value if not
20+
GetPrivateProfileString(constchar*theSection,/* section name */
21+
constchar*theKey,/* search key name */
22+
constchar*theDefault,/* default value if not
2323
* found */
2424
char*theReturnBuffer,/* return valuse stored
2525
* here */
2626
size_ttheBufferLength,/* byte length of return
2727
* buffer */
28-
char*theIniFileName);/* pathname of ini file
28+
constchar*theIniFileName);/* pathname of ini file
2929
* to search */
3030

3131
DWORD
32-
WritePrivateProfileString(char*theSection,/* section name */
33-
char*theKey,/* write key name */
34-
char*theBuffer,/* input buffer */
35-
char*theIniFileName);/* pathname of ini file
32+
WritePrivateProfileString(constchar*theSection,/* section name */
33+
constchar*theKey,/* write key name */
34+
constchar*theBuffer,/* input buffer */
35+
constchar*theIniFileName);/* pathname of ini file
3636
* to write */
3737

3838
#ifdef__cplusplus

‎src/interfaces/odbc/qresult.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
#defineFALSE(BOOL)0
3333
#endif
3434

35-
externGLOBAL_VALUESglobals;
36-
3735

3836
/*
3937
*Used for building a Manual Result only
@@ -119,7 +117,7 @@ QR_Constructor()
119117
rv->cursor=NULL;
120118
rv->aborted= FALSE;
121119

122-
rv->cache_size=globals.fetch_max;
120+
rv->cache_size=0;
123121
rv->rowset_size=1;
124122
}
125123

‎src/interfaces/odbc/statement.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,10 @@ struct StatementClass_
232232
/*misc info */
233233
#defineSC_set_pre_executable(a) (a->miscinfo |= 1L)
234234
#defineSC_no_pre_executable(a)(a->miscinfo &= ~1L)
235-
#defineSC_is_pre_executable(a)(a->miscinfo & 1L != 0)
235+
#defineSC_is_pre_executable(a)((a->miscinfo & 1L) != 0)
236236
#defineSC_set_fetchcursor(a)(a->miscinfo |= 2L)
237237
#defineSC_no_fetchcursor(a)(a->miscinfo &= ~2L)
238-
#defineSC_is_fetchcursor(a)(a->miscinfo & 2L != 0)
238+
#defineSC_is_fetchcursor(a)((a->miscinfo & 2L) != 0)
239239

240240
/*Statement prototypes */
241241
StatementClass*SC_Constructor(void);

‎src/interfaces/odbc/win32.mak

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ BSC32_FLAGS=/nologo /o"$(OUTDIR)\psqlodbc.bsc"
139139
BSC32_SBRS=\
140140

141141
LINK32=link.exe
142-
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\psqlodbc.pdb" /machine:I386 /def:"psqlodbc.def" /out:"$(OUTDIR)\psqlodbc.dll" /implib:"$(OUTDIR)\psqlodbc.lib"
143-
DEF_FILE= "psqlodbc.def"
142+
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\psqlodbc.pdb" /machine:I386 /def:"psqlodbc_win32.def" /out:"$(OUTDIR)\psqlodbc.dll" /implib:"$(OUTDIR)\psqlodbc.lib"
143+
DEF_FILE= "psqlodbc_win32.def"
144144
LINK32_OBJS=\
145145
"$(INTDIR)\bind.obj"\
146146
"$(INTDIR)\columninfo.obj"\
@@ -277,8 +277,8 @@ BSC32_FLAGS=/nologo /o"$(OUTDIR)\psqlodbc.bsc"
277277
BSC32_SBRS=\
278278

279279
LINK32=link.exe
280-
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\psqlodbc.pdb" /debug /machine:I386 /def:"psqlodbc.def" /out:"$(OUTDIR)\psqlodbc.dll" /implib:"$(OUTDIR)\psqlodbc.lib" /pdbtype:sept
281-
DEF_FILE= "psqlodbc.def"
280+
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\psqlodbc.pdb" /debug /machine:I386 /def:"psqlodbc_win32.def" /out:"$(OUTDIR)\psqlodbc.dll" /implib:"$(OUTDIR)\psqlodbc.lib" /pdbtype:sept
281+
DEF_FILE= "psqlodbc_win32.def"
282282
LINK32_OBJS=\
283283
"$(INTDIR)\bind.obj"\
284284
"$(INTDIR)\columninfo.obj"\

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp