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
550de5db
Commit
550de5db
authored
Dec 29, 1998
by
Byron Nikolaidis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor fixes to compile on unix for v6-40-0002
parent
a75f2d21
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
149 additions
and
137 deletions
+149
-137
src/interfaces/odbc/execute.c
src/interfaces/odbc/execute.c
+2
-0
src/interfaces/odbc/misc.h
src/interfaces/odbc/misc.h
+1
-1
src/interfaces/odbc/options.c
src/interfaces/odbc/options.c
+6
-0
src/interfaces/odbc/qresult.c
src/interfaces/odbc/qresult.c
+1
-1
src/interfaces/odbc/qresult.h
src/interfaces/odbc/qresult.h
+1
-1
src/interfaces/odbc/results.c
src/interfaces/odbc/results.c
+0
-133
src/interfaces/odbc/statement.c
src/interfaces/odbc/statement.c
+136
-0
src/interfaces/odbc/statement.h
src/interfaces/odbc/statement.h
+2
-1
No files found.
src/interfaces/odbc/execute.c
View file @
550de5db
...
...
@@ -372,8 +372,10 @@ RETCODE SQL_API SQLCancel(
static
char
*
func
=
"SQLCancel"
;
StatementClass
*
stmt
=
(
StatementClass
*
)
hstmt
;
RETCODE
result
;
#ifdef WIN32
HMODULE
hmodule
;
FARPROC
addr
;
#endif
mylog
(
"%s: entering...
\n
"
,
func
);
...
...
src/interfaces/odbc/misc.h
View file @
550de5db
...
...
@@ -26,7 +26,7 @@
portion of the registry. You may have to manually add this key.
This logfile is intended for development use, not for an end user!
*/
//
#define MY_LOG
#define MY_LOG
/* Uncomment Q_LOG to compile in the qlog() statements (Communications log, i.e. CommLog).
...
...
src/interfaces/odbc/options.c
View file @
550de5db
...
...
@@ -36,6 +36,12 @@
extern
GLOBAL_VALUES
globals
;
RETCODE
set_statement_option
(
ConnectionClass
*
conn
,
StatementClass
*
stmt
,
UWORD
fOption
,
UDWORD
vParam
);
RETCODE
set_statement_option
(
ConnectionClass
*
conn
,
StatementClass
*
stmt
,
...
...
src/interfaces/odbc/qresult.c
View file @
550de5db
...
...
@@ -77,7 +77,7 @@ QR_inc_base(QResultClass *self, int base_inc)
/************************************/
QResultClass
*
QR_Constructor
()
QR_Constructor
(
void
)
{
QResultClass
*
rv
;
...
...
src/interfaces/odbc/qresult.h
View file @
550de5db
...
...
@@ -98,7 +98,7 @@ struct QResultClass_ {
#define QR_get_status(self) (self->status)
// Core Functions
QResultClass
*
QR_Constructor
();
QResultClass
*
QR_Constructor
(
void
);
void
QR_Destructor
(
QResultClass
*
self
);
char
QR_read_tuple
(
QResultClass
*
self
,
char
binary
);
int
QR_next_tuple
(
QResultClass
*
self
);
...
...
src/interfaces/odbc/results.c
View file @
550de5db
...
...
@@ -740,139 +740,6 @@ mylog("SQLGetData: enter, stmt=%u\n", stmt);
}
}
RETCODE
SC_fetch
(
StatementClass
*
stmt
)
{
static
char
*
func
=
"SC_fetch"
;
QResultClass
*
res
=
stmt
->
result
;
int
retval
,
result
;
Int2
num_cols
,
lf
;
Oid
type
;
char
*
value
;
ColumnInfoClass
*
ci
;
// TupleField *tupleField;
stmt
->
last_fetch_count
=
0
;
ci
=
QR_get_fields
(
res
);
/* the column info */
mylog
(
"manual_result = %d, use_declarefetch = %d
\n
"
,
stmt
->
manual_result
,
globals
.
use_declarefetch
);
if
(
stmt
->
manual_result
||
!
globals
.
use_declarefetch
)
{
if
(
stmt
->
currTuple
>=
QR_get_num_tuples
(
res
)
-
1
||
(
stmt
->
options
.
maxRows
>
0
&&
stmt
->
currTuple
==
stmt
->
options
.
maxRows
-
1
))
{
/* if at the end of the tuples, return "no data found"
and set the cursor past the end of the result set
*/
stmt
->
currTuple
=
QR_get_num_tuples
(
res
);
return
SQL_NO_DATA_FOUND
;
}
mylog
(
"**** SQLFetch: manual_result
\n
"
);
(
stmt
->
currTuple
)
++
;
}
else
{
// read from the cache or the physical next tuple
retval
=
QR_next_tuple
(
res
);
if
(
retval
<
0
)
{
mylog
(
"**** SQLFetch: end_tuples
\n
"
);
return
SQL_NO_DATA_FOUND
;
}
else
if
(
retval
>
0
)
(
stmt
->
currTuple
)
++
;
// all is well
else
{
mylog
(
"SQLFetch: error
\n
"
);
stmt
->
errornumber
=
STMT_EXEC_ERROR
;
stmt
->
errormsg
=
"Error fetching next row"
;
SC_log_error
(
func
,
""
,
stmt
);
return
SQL_ERROR
;
}
}
num_cols
=
QR_NumResultCols
(
res
);
result
=
SQL_SUCCESS
;
stmt
->
last_fetch_count
=
1
;
for
(
lf
=
0
;
lf
<
num_cols
;
lf
++
)
{
mylog
(
"fetch: cols=%d, lf=%d, stmt = %u, stmt->bindings = %u, buffer[] = %u
\n
"
,
num_cols
,
lf
,
stmt
,
stmt
->
bindings
,
stmt
->
bindings
[
lf
].
buffer
);
/* reset for SQLGetData */
stmt
->
bindings
[
lf
].
data_left
=
-
1
;
if
(
stmt
->
bindings
[
lf
].
buffer
!=
NULL
)
{
// this column has a binding
// type = QR_get_field_type(res, lf);
type
=
CI_get_oid
(
ci
,
lf
);
/* speed things up */
mylog
(
"type = %d
\n
"
,
type
);
if
(
stmt
->
manual_result
)
{
value
=
QR_get_value_manual
(
res
,
stmt
->
currTuple
,
lf
);
mylog
(
"manual_result
\n
"
);
}
else
if
(
globals
.
use_declarefetch
)
value
=
QR_get_value_backend
(
res
,
lf
);
else
{
value
=
QR_get_value_backend_row
(
res
,
stmt
->
currTuple
,
lf
);
}
mylog
(
"value = '%s'
\n
"
,
(
value
==
NULL
)
?
"<NULL>"
:
value
);
retval
=
copy_and_convert_field_bindinfo
(
stmt
,
type
,
value
,
lf
);
mylog
(
"copy_and_convert: retval = %d
\n
"
,
retval
);
switch
(
retval
)
{
case
COPY_OK
:
break
;
/* OK, do next bound column */
case
COPY_UNSUPPORTED_TYPE
:
stmt
->
errormsg
=
"Received an unsupported type from Postgres."
;
stmt
->
errornumber
=
STMT_RESTRICTED_DATA_TYPE_ERROR
;
SC_log_error
(
func
,
""
,
stmt
);
result
=
SQL_ERROR
;
break
;
case
COPY_UNSUPPORTED_CONVERSION
:
stmt
->
errormsg
=
"Couldn't handle the necessary data type conversion."
;
stmt
->
errornumber
=
STMT_RESTRICTED_DATA_TYPE_ERROR
;
SC_log_error
(
func
,
""
,
stmt
);
result
=
SQL_ERROR
;
break
;
case
COPY_RESULT_TRUNCATED
:
stmt
->
errornumber
=
STMT_TRUNCATED
;
stmt
->
errormsg
=
"The buffer was too small for the result."
;
result
=
SQL_SUCCESS_WITH_INFO
;
break
;
case
COPY_GENERAL_ERROR
:
/* error msg already filled in */
SC_log_error
(
func
,
""
,
stmt
);
result
=
SQL_ERROR
;
break
;
/* This would not be meaningful in SQLFetch. */
case
COPY_NO_DATA_FOUND
:
break
;
default:
stmt
->
errormsg
=
"Unrecognized return value from copy_and_convert_field."
;
stmt
->
errornumber
=
STMT_INTERNAL_ERROR
;
SC_log_error
(
func
,
""
,
stmt
);
result
=
SQL_ERROR
;
break
;
}
}
}
return
result
;
}
// Returns data for bound columns in the current row ("hstmt->iCursor"),
...
...
src/interfaces/odbc/statement.c
View file @
550de5db
...
...
@@ -566,6 +566,142 @@ char rv;
return
rv
;
}
RETCODE
SC_fetch
(
StatementClass
*
self
)
{
static
char
*
func
=
"SC_fetch"
;
QResultClass
*
res
=
self
->
result
;
int
retval
,
result
;
Int2
num_cols
,
lf
;
Oid
type
;
char
*
value
;
ColumnInfoClass
*
ci
;
// TupleField *tupleField;
self
->
last_fetch_count
=
0
;
ci
=
QR_get_fields
(
res
);
/* the column info */
mylog
(
"manual_result = %d, use_declarefetch = %d
\n
"
,
self
->
manual_result
,
globals
.
use_declarefetch
);
if
(
self
->
manual_result
||
!
globals
.
use_declarefetch
)
{
if
(
self
->
currTuple
>=
QR_get_num_tuples
(
res
)
-
1
||
(
self
->
options
.
maxRows
>
0
&&
self
->
currTuple
==
self
->
options
.
maxRows
-
1
))
{
/* if at the end of the tuples, return "no data found"
and set the cursor past the end of the result set
*/
self
->
currTuple
=
QR_get_num_tuples
(
res
);
return
SQL_NO_DATA_FOUND
;
}
mylog
(
"**** SQLFetch: manual_result
\n
"
);
(
self
->
currTuple
)
++
;
}
else
{
// read from the cache or the physical next tuple
retval
=
QR_next_tuple
(
res
);
if
(
retval
<
0
)
{
mylog
(
"**** SQLFetch: end_tuples
\n
"
);
return
SQL_NO_DATA_FOUND
;
}
else
if
(
retval
>
0
)
(
self
->
currTuple
)
++
;
// all is well
else
{
mylog
(
"SQLFetch: error
\n
"
);
self
->
errornumber
=
STMT_EXEC_ERROR
;
self
->
errormsg
=
"Error fetching next row"
;
SC_log_error
(
func
,
""
,
self
);
return
SQL_ERROR
;
}
}
num_cols
=
QR_NumResultCols
(
res
);
result
=
SQL_SUCCESS
;
self
->
last_fetch_count
=
1
;
for
(
lf
=
0
;
lf
<
num_cols
;
lf
++
)
{
mylog
(
"fetch: cols=%d, lf=%d, self = %u, self->bindings = %u, buffer[] = %u
\n
"
,
num_cols
,
lf
,
self
,
self
->
bindings
,
self
->
bindings
[
lf
].
buffer
);
/* reset for SQLGetData */
self
->
bindings
[
lf
].
data_left
=
-
1
;
if
(
self
->
bindings
[
lf
].
buffer
!=
NULL
)
{
// this column has a binding
// type = QR_get_field_type(res, lf);
type
=
CI_get_oid
(
ci
,
lf
);
/* speed things up */
mylog
(
"type = %d
\n
"
,
type
);
if
(
self
->
manual_result
)
{
value
=
QR_get_value_manual
(
res
,
self
->
currTuple
,
lf
);
mylog
(
"manual_result
\n
"
);
}
else
if
(
globals
.
use_declarefetch
)
value
=
QR_get_value_backend
(
res
,
lf
);
else
{
value
=
QR_get_value_backend_row
(
res
,
self
->
currTuple
,
lf
);
}
mylog
(
"value = '%s'
\n
"
,
(
value
==
NULL
)
?
"<NULL>"
:
value
);
retval
=
copy_and_convert_field_bindinfo
(
self
,
type
,
value
,
lf
);
mylog
(
"copy_and_convert: retval = %d
\n
"
,
retval
);
switch
(
retval
)
{
case
COPY_OK
:
break
;
/* OK, do next bound column */
case
COPY_UNSUPPORTED_TYPE
:
self
->
errormsg
=
"Received an unsupported type from Postgres."
;
self
->
errornumber
=
STMT_RESTRICTED_DATA_TYPE_ERROR
;
SC_log_error
(
func
,
""
,
self
);
result
=
SQL_ERROR
;
break
;
case
COPY_UNSUPPORTED_CONVERSION
:
self
->
errormsg
=
"Couldn't handle the necessary data type conversion."
;
self
->
errornumber
=
STMT_RESTRICTED_DATA_TYPE_ERROR
;
SC_log_error
(
func
,
""
,
self
);
result
=
SQL_ERROR
;
break
;
case
COPY_RESULT_TRUNCATED
:
self
->
errornumber
=
STMT_TRUNCATED
;
self
->
errormsg
=
"The buffer was too small for the result."
;
result
=
SQL_SUCCESS_WITH_INFO
;
break
;
case
COPY_GENERAL_ERROR
:
/* error msg already filled in */
SC_log_error
(
func
,
""
,
self
);
result
=
SQL_ERROR
;
break
;
/* This would not be meaningful in SQLFetch. */
case
COPY_NO_DATA_FOUND
:
break
;
default:
self
->
errormsg
=
"Unrecognized return value from copy_and_convert_field."
;
self
->
errornumber
=
STMT_INTERNAL_ERROR
;
SC_log_error
(
func
,
""
,
self
);
result
=
SQL_ERROR
;
break
;
}
}
}
return
result
;
}
RETCODE
SC_execute
(
StatementClass
*
self
)
{
static
char
*
func
=
"SC_execute"
;
...
...
src/interfaces/odbc/statement.h
View file @
550de5db
...
...
@@ -202,7 +202,8 @@ char SC_recycle_statement(StatementClass *self);
void
SC_clear_error
(
StatementClass
*
self
);
char
SC_get_error
(
StatementClass
*
self
,
int
*
number
,
char
**
message
);
char
*
SC_create_errormsg
(
StatementClass
*
self
);
RETCODE
SC_execute
(
StatementClass
*
stmt
);
RETCODE
SC_execute
(
StatementClass
*
self
);
RETCODE
SC_fetch
(
StatementClass
*
self
);
void
SC_free_params
(
StatementClass
*
self
,
char
option
);
void
SC_log_error
(
char
*
func
,
char
*
desc
,
StatementClass
*
self
);
...
...
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