Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
8aad28da
Commit
8aad28da
authored
Jan 05, 1999
by
Byron Nikolaidis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mini Update #2 -- final fixes for buffer lengths, null buffers, truncation
parent
1bbe55c7
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
207 additions
and
150 deletions
+207
-150
src/interfaces/odbc/connection.h
src/interfaces/odbc/connection.h
+2
-0
src/interfaces/odbc/drvconn.c
src/interfaces/odbc/drvconn.c
+38
-19
src/interfaces/odbc/environ.c
src/interfaces/odbc/environ.c
+1
-0
src/interfaces/odbc/execute.c
src/interfaces/odbc/execute.c
+33
-4
src/interfaces/odbc/results.c
src/interfaces/odbc/results.c
+133
-127
No files found.
src/interfaces/odbc/connection.h
View file @
8aad28da
...
@@ -65,6 +65,8 @@ typedef enum {
...
@@ -65,6 +65,8 @@ typedef enum {
#define CONN_OPTION_VALUE_CHANGED 213
#define CONN_OPTION_VALUE_CHANGED 213
#define CONN_VALUE_OUT_OF_RANGE 214
#define CONN_VALUE_OUT_OF_RANGE 214
#define CONN_TRUNCATED 215
/* Conn_status defines */
/* Conn_status defines */
#define CONN_IN_AUTOCOMMIT 0x01
#define CONN_IN_AUTOCOMMIT 0x01
#define CONN_IN_TRANSACTION 0x02
#define CONN_IN_TRANSACTION 0x02
...
...
src/interfaces/odbc/drvconn.c
View file @
8aad28da
...
@@ -79,12 +79,14 @@ static char *func = "SQLDriverConnect";
...
@@ -79,12 +79,14 @@ static char *func = "SQLDriverConnect";
ConnectionClass
*
conn
=
(
ConnectionClass
*
)
hdbc
;
ConnectionClass
*
conn
=
(
ConnectionClass
*
)
hdbc
;
ConnInfo
*
ci
;
ConnInfo
*
ci
;
#ifdef WIN32
#ifdef WIN32
RETCODE
dialog_result
;
RETCODE
dialog_result
,
result
;
#endif
#endif
char
connStrIn
[
MAX_CONNECT_STRING
];
char
connStrIn
[
MAX_CONNECT_STRING
];
char
connStrOut
[
MAX_CONNECT_STRING
];
char
connStrOut
[
MAX_CONNECT_STRING
];
int
retval
;
int
retval
;
char
password_required
=
FALSE
;
char
password_required
=
FALSE
;
int
len
=
0
;
mylog
(
"%s: entering...
\n
"
,
func
);
mylog
(
"%s: entering...
\n
"
,
func
);
...
@@ -166,22 +168,6 @@ dialog:
...
@@ -166,22 +168,6 @@ dialog:
return
SQL_NO_DATA_FOUND
;
return
SQL_NO_DATA_FOUND
;
}
}
if
(
szConnStrOut
)
{
/* Return the completed string to the caller.
Only construct the connect string if a dialog was put up,
otherwise, just copy the connection input string to the output.
*/
makeConnectString
(
connStrOut
,
ci
);
if
(
pcbConnStrOut
)
{
*
pcbConnStrOut
=
strlen
(
connStrOut
);
}
strncpy_null
(
szConnStrOut
,
connStrOut
,
cbConnStrOutMax
);
}
mylog
(
"szConnStrOut = '%s'
\n
"
,
szConnStrOut
);
qlog
(
"conn=%u, SQLDriverConnect(out)='%s'
\n
"
,
conn
,
szConnStrOut
);
// do the actual connect
// do the actual connect
retval
=
CC_connect
(
conn
,
password_required
);
retval
=
CC_connect
(
conn
,
password_required
);
...
@@ -205,8 +191,41 @@ dialog:
...
@@ -205,8 +191,41 @@ dialog:
return
SQL_ERROR
;
return
SQL_ERROR
;
}
}
mylog
(
"SQLDRiverConnect: returning success
\n
"
);
/*********************************************/
return
SQL_SUCCESS
;
/* Create the Output Connection String */
/*********************************************/
result
=
SQL_SUCCESS
;
makeConnectString
(
connStrOut
,
ci
);
len
=
strlen
(
connStrOut
);
if
(
szConnStrOut
)
{
/* Return the completed string to the caller. The correct method is to
only construct the connect string if a dialog was put up, otherwise,
it should just copy the connection input string to the output.
However, it seems ok to just always construct an output string. There
are possible bad side effects on working applications (Access) by
implementing the correct behavior, anyway.
*/
strncpy_null
(
szConnStrOut
,
connStrOut
,
cbConnStrOutMax
);
if
(
len
>=
cbConnStrOutMax
)
{
result
=
SQL_SUCCESS_WITH_INFO
;
conn
->
errornumber
=
CONN_TRUNCATED
;
conn
->
errormsg
=
"The buffer was too small for the result."
;
}
}
if
(
pcbConnStrOut
)
*
pcbConnStrOut
=
len
;
mylog
(
"szConnStrOut = '%s'
\n
"
,
szConnStrOut
);
qlog
(
"conn=%u, SQLDriverConnect(out)='%s'
\n
"
,
conn
,
szConnStrOut
);
mylog
(
"SQLDRiverConnect: returning %d
\n
"
,
result
);
return
result
;
}
}
#ifdef WIN32
#ifdef WIN32
...
...
src/interfaces/odbc/environ.c
View file @
8aad28da
...
@@ -242,6 +242,7 @@ int status;
...
@@ -242,6 +242,7 @@ int status;
strcpy
(
szSqlState
,
"01S02"
);
strcpy
(
szSqlState
,
"01S02"
);
break
;
break
;
case
STMT_TRUNCATED
:
case
STMT_TRUNCATED
:
case
CONN_TRUNCATED
:
strcpy
(
szSqlState
,
"01004"
);
strcpy
(
szSqlState
,
"01004"
);
// data truncated
// data truncated
break
;
break
;
...
...
src/interfaces/odbc/execute.c
View file @
8aad28da
...
@@ -431,7 +431,8 @@ FARPROC addr;
...
@@ -431,7 +431,8 @@ FARPROC addr;
// - - - - - - - - -
// - - - - - - - - -
// Returns the SQL string as modified by the driver.
// Returns the SQL string as modified by the driver.
// Currently, just copy the input string without modification
// observing buffer limits and truncation.
RETCODE
SQL_API
SQLNativeSql
(
RETCODE
SQL_API
SQLNativeSql
(
HDBC
hdbc
,
HDBC
hdbc
,
UCHAR
FAR
*
szSqlStrIn
,
UCHAR
FAR
*
szSqlStrIn
,
...
@@ -441,12 +442,40 @@ RETCODE SQL_API SQLNativeSql(
...
@@ -441,12 +442,40 @@ RETCODE SQL_API SQLNativeSql(
SDWORD
FAR
*
pcbSqlStr
)
SDWORD
FAR
*
pcbSqlStr
)
{
{
static
char
*
func
=
"SQLNativeSql"
;
static
char
*
func
=
"SQLNativeSql"
;
int
len
=
0
;
char
*
ptr
;
ConnectionClass
*
conn
=
(
ConnectionClass
*
)
hdbc
;
RETCODE
result
;
mylog
(
"%s: entering...
\n
"
,
func
);
mylog
(
"%s: entering...cbSqlStrIn=%d
\n
"
,
func
,
cbSqlStrIn
);
ptr
=
(
cbSqlStrIn
==
0
)
?
""
:
make_string
(
szSqlStrIn
,
cbSqlStrIn
,
NULL
);
if
(
!
ptr
)
{
conn
->
errornumber
=
CONN_NO_MEMORY_ERROR
;
conn
->
errormsg
=
"No memory available to store native sql string"
;
CC_log_error
(
func
,
""
,
conn
);
return
SQL_ERROR
;
}
result
=
SQL_SUCCESS
;
len
=
strlen
(
ptr
);
if
(
szSqlStr
)
{
strncpy_null
(
szSqlStr
,
ptr
,
cbSqlStrMax
);
if
(
len
>=
cbSqlStrMax
)
{
result
=
SQL_SUCCESS_WITH_INFO
;
conn
->
errornumber
=
STMT_TRUNCATED
;
conn
->
errormsg
=
"The buffer was too small for the result."
;
}
}
if
(
pcbSqlStr
)
*
pcbSqlStr
=
len
;
strncpy_null
(
szSqlStr
,
szSqlStrIn
,
cbSqlStrMax
);
free
(
ptr
);
return
SQL_SUCCESS
;
return
result
;
}
}
// - - - - - - - - -
// - - - - - - - - -
...
...
src/interfaces/odbc/results.c
View file @
8aad28da
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment