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
01b5efa5
Commit
01b5efa5
authored
Dec 11, 2000
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ODBC compile, prevent ODBCVER warning, though the version numbers go
not match.
parent
0cbfde72
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
92 deletions
+99
-92
src/interfaces/odbc/info.c
src/interfaces/odbc/info.c
+95
-92
src/interfaces/odbc/isql.h
src/interfaces/odbc/isql.h
+2
-0
src/interfaces/odbc/psqlodbc.h
src/interfaces/odbc/psqlodbc.h
+2
-0
No files found.
src/interfaces/odbc/info.c
View file @
01b5efa5
...
...
@@ -2255,12 +2255,15 @@ char tables_query[MAX_STATEMENT_LEN];
char
trig_deferrable
[
2
];
char
trig_initdeferred
[
2
];
char
trig_args
[
1024
];
char
upd_rule
[
MAX_
NAME_LEN
],
del_rule
[
MAX_NAM
E_LEN
];
char
upd_rule
[
MAX_
TABLE_LEN
],
del_rule
[
MAX_TABL
E_LEN
];
char
pk_table_needed
[
MAX_TABLE_LEN
+
1
];
char
fk_table_needed
[
MAX_TABLE_LEN
+
1
];
char
*
pkey_ptr
,
*
fkey_ptr
,
*
pk_table
,
*
fk_table
;
int
i
,
j
,
k
,
num_keys
;
SWORD
trig_nargs
,
upd_rule_type
,
del_rule_type
,
defer_type
;
SWORD
trig_nargs
,
upd_rule_type
=
0
,
del_rule_type
=
0
;
#if (ODBCVER >= 0x0300)
SWORD
defer_type
;
#endif
char
pkey
[
MAX_INFO_STRING
];
Int2
result_cols
;
...
...
@@ -2694,136 +2697,136 @@ Int2 result_cols;
return
SQL_ERROR
;
}
result
=
SQLBindCol
(
htbl_stmt
,
5
,
SQL_C_CHAR
,
upd_rule
,
sizeof
(
upd_rule
),
NULL
);
if
((
result
!=
SQL_SUCCESS
)
&&
(
result
!=
SQL_SUCCESS_WITH_INFO
))
{
stmt
->
errormsg
=
tbl_stmt
->
errormsg
;
result
=
SQLBindCol
(
htbl_stmt
,
5
,
SQL_C_CHAR
,
upd_rule
,
sizeof
(
upd_rule
),
NULL
);
if
((
result
!=
SQL_SUCCESS
)
&&
(
result
!=
SQL_SUCCESS_WITH_INFO
))
{
stmt
->
errormsg
=
tbl_stmt
->
errormsg
;
stmt
->
errornumber
=
tbl_stmt
->
errornumber
;
SC_log_error
(
func
,
""
,
stmt
);
SQLFreeStmt
(
htbl_stmt
,
SQL_DROP
);
return
SQL_ERROR
;
}
result
=
SQLBindCol
(
htbl_stmt
,
6
,
SQL_C_CHAR
,
del_rule
,
sizeof
(
del_rule
),
NULL
);
if
((
result
!=
SQL_SUCCESS
)
&&
(
result
!=
SQL_SUCCESS_WITH_INFO
))
{
stmt
->
errormsg
=
tbl_stmt
->
errormsg
;
stmt
->
errornumber
=
tbl_stmt
->
errornumber
;
result
=
SQLBindCol
(
htbl_stmt
,
6
,
SQL_C_CHAR
,
del_rule
,
sizeof
(
del_rule
),
NULL
);
if
((
result
!=
SQL_SUCCESS
)
&&
(
result
!=
SQL_SUCCESS_WITH_INFO
))
{
stmt
->
errormsg
=
tbl_stmt
->
errormsg
;
stmt
->
errornumber
=
tbl_stmt
->
errornumber
;
SC_log_error
(
func
,
""
,
stmt
);
SQLFreeStmt
(
htbl_stmt
,
SQL_DROP
);
SQLFreeStmt
(
htbl_stmt
,
SQL_DROP
);
return
SQL_ERROR
;
}
result
=
SQLFetch
(
htbl_stmt
);
if
(
result
==
SQL_NO_DATA_FOUND
)
return
SQL_SUCCESS
;
result
=
SQLFetch
(
htbl_stmt
);
if
(
result
==
SQL_NO_DATA_FOUND
)
return
SQL_SUCCESS
;
if
(
result
!=
SQL_SUCCESS
)
{
stmt
->
errormsg
=
SC_create_errormsg
(
htbl_stmt
);
stmt
->
errornumber
=
tbl_stmt
->
errornumber
;
if
(
result
!=
SQL_SUCCESS
)
{
stmt
->
errormsg
=
SC_create_errormsg
(
htbl_stmt
);
stmt
->
errornumber
=
tbl_stmt
->
errornumber
;
SC_log_error
(
func
,
""
,
stmt
);
SQLFreeStmt
(
htbl_stmt
,
SQL_DROP
);
SQLFreeStmt
(
htbl_stmt
,
SQL_DROP
);
return
SQL_ERROR
;
}
while
(
result
==
SQL_SUCCESS
)
{
/* Calculate the number of key parts */
num_keys
=
(
trig_nargs
-
4
)
/
2
;;
num_keys
=
(
trig_nargs
-
4
)
/
2
;;
/* Handle action (i.e., 'cascade', 'restrict', 'setnull') */
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_cascade_upd"
))
{
upd_rule_type
=
SQL_CASCADE
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_noaction_upd"
))
{
upd_rule_type
=
SQL_NO_ACTION
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_restrict_upd"
))
{
upd_rule_type
=
SQL_NO_ACTION
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_setdefault_upd"
))
{
upd_rule_type
=
SQL_SET_DEFAULT
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_setnull_upd"
))
{
upd_rule_type
=
SQL_SET_NULL
;
}
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_cascade_del"
))
{
del_rule_type
=
SQL_CASCADE
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_noaction_del"
))
{
del_rule_type
=
SQL_NO_ACTION
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_restrict_del"
))
{
del_rule_type
=
SQL_NO_ACTION
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_setdefault_del"
))
{
del_rule_type
=
SQL_SET_DEFAULT
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_setnull_del"
))
{
del_rule_type
=
SQL_SET_NULL
;
}
#if (ODBCVER >= 0x0300)
/* Set deferrability type */
if
(
!
strcmp
(
trig_initdeferred
,
"y"
))
{
defer_type
=
SQL_INITIALLY_DEFERRED
;
}
else
if
(
!
strcmp
(
trig_deferrable
,
"y"
))
{
defer_type
=
SQL_INITIALLY_IMMEDIATE
;
}
else
{
defer_type
=
SQL_NOT_DEFERRABLE
;
}
#endif
/* ODBCVER >= 0x0300 */
mylog
(
"Foreign Key Case#1: trig_nargs = %d, num_keys = %d
\n
"
,
trig_nargs
,
num_keys
);
/* Get to first primary key */
pkey_ptr
=
trig_args
;
for
(
i
=
0
;
i
<
5
;
i
++
)
pkey_ptr
+=
strlen
(
pkey_ptr
)
+
1
;
/* Get to first foreign table */
fk_table
=
trig_args
;
fk_table
+=
strlen
(
fk_table
)
+
1
;
/* Get to first foreign key */
fkey_ptr
=
trig_args
;
for
(
k
=
0
;
k
<
4
;
k
++
)
fkey_ptr
+=
strlen
(
fkey_ptr
)
+
1
;
for
(
k
=
0
;
k
<
num_keys
;
k
++
)
{
mylog
(
"pkey_ptr = '%s', fk_table = '%s', fkey_ptr = '%s'
\n
"
,
pkey_ptr
,
fk_table
,
fkey_ptr
);
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_cascade_upd"
))
{
upd_rule_type
=
SQL_CASCADE
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_noaction_upd"
))
{
upd_rule_type
=
SQL_NO_ACTION
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_restrict_upd"
))
{
upd_rule_type
=
SQL_NO_ACTION
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_setdefault_upd"
))
{
upd_rule_type
=
SQL_SET_DEFAULT
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_setnull_upd"
))
{
upd_rule_type
=
SQL_SET_NULL
;
}
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_cascade_del"
))
{
del_rule_type
=
SQL_CASCADE
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_noaction_del"
))
{
del_rule_type
=
SQL_NO_ACTION
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_restrict_del"
))
{
del_rule_type
=
SQL_NO_ACTION
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_setdefault_del"
))
{
del_rule_type
=
SQL_SET_DEFAULT
;
}
else
if
(
!
strcmp
(
upd_rule
,
"RI_FKey_setnull_del"
))
{
del_rule_type
=
SQL_SET_NULL
;
}
#if (ODBCVER >= 0x0300)
/* Set deferrability type */
if
(
!
strcmp
(
trig_initdeferred
,
"y"
))
{
defer_type
=
SQL_INITIALLY_DEFERRED
;
}
else
if
(
!
strcmp
(
trig_deferrable
,
"y"
))
{
defer_type
=
SQL_INITIALLY_IMMEDIATE
;
}
else
{
defer_type
=
SQL_NOT_DEFERRABLE
;
}
#endif
/* ODBCVER >= 0x0300 */
mylog
(
"Foreign Key Case#1: trig_nargs = %d, num_keys = %d
\n
"
,
trig_nargs
,
num_keys
);
/* Get to first primary key */
pkey_ptr
=
trig_args
;
for
(
i
=
0
;
i
<
5
;
i
++
)
pkey_ptr
+=
strlen
(
pkey_ptr
)
+
1
;
/* Get to first foreign table */
fk_table
=
trig_args
;
fk_table
+=
strlen
(
fk_table
)
+
1
;
/* Get to first foreign key */
fkey_ptr
=
trig_args
;
for
(
k
=
0
;
k
<
4
;
k
++
)
fkey_ptr
+=
strlen
(
fkey_ptr
)
+
1
;
for
(
k
=
0
;
k
<
num_keys
;
k
++
)
{
mylog
(
"pkey_ptr = '%s', fk_table = '%s', fkey_ptr = '%s'
\n
"
,
pkey_ptr
,
fk_table
,
fkey_ptr
);
row
=
(
TupleNode
*
)
malloc
(
sizeof
(
TupleNode
)
+
(
result_cols
-
1
)
*
sizeof
(
TupleField
));
mylog
(
"pk_table_needed = '%s', pkey_ptr = '%s'
\n
"
,
pk_table_needed
,
pkey_ptr
);
mylog
(
"pk_table_needed = '%s', pkey_ptr = '%s'
\n
"
,
pk_table_needed
,
pkey_ptr
);
set_tuplefield_null
(
&
row
->
tuple
[
0
]);
set_tuplefield_string
(
&
row
->
tuple
[
1
],
""
);
set_tuplefield_string
(
&
row
->
tuple
[
2
],
pk_table_needed
);
set_tuplefield_string
(
&
row
->
tuple
[
3
],
pkey_ptr
);
set_tuplefield_string
(
&
row
->
tuple
[
2
],
pk_table_needed
);
set_tuplefield_string
(
&
row
->
tuple
[
3
],
pkey_ptr
);
mylog
(
"fk_table = '%s', fkey_ptr = '%s'
\n
"
,
fk_table
,
fkey_ptr
);
mylog
(
"fk_table = '%s', fkey_ptr = '%s'
\n
"
,
fk_table
,
fkey_ptr
);
set_tuplefield_null
(
&
row
->
tuple
[
4
]);
set_tuplefield_string
(
&
row
->
tuple
[
5
],
""
);
set_tuplefield_string
(
&
row
->
tuple
[
6
],
fk_table
);
set_tuplefield_string
(
&
row
->
tuple
[
7
],
fkey_ptr
);
set_tuplefield_string
(
&
row
->
tuple
[
7
],
fkey_ptr
);
set_tuplefield_int2
(
&
row
->
tuple
[
8
],
(
Int2
)
(
k
+
1
));
set_tuplefield_int2
(
&
row
->
tuple
[
8
],
(
Int2
)
(
k
+
1
));
mylog
(
"upd_rule = %d, del_rule= %d"
,
upd_rule_type
,
del_rule_type
);
set_nullfield_int2
(
&
row
->
tuple
[
9
],
(
Int2
)
upd_rule_type
);
set_nullfield_int2
(
&
row
->
tuple
[
10
],
(
Int2
)
del_rule_type
);
mylog
(
"upd_rule = %d, del_rule= %d"
,
upd_rule_type
,
del_rule_type
);
set_nullfield_int2
(
&
row
->
tuple
[
9
],
(
Int2
)
upd_rule_type
);
set_nullfield_int2
(
&
row
->
tuple
[
10
],
(
Int2
)
del_rule_type
);
set_tuplefield_null
(
&
row
->
tuple
[
11
]);
set_tuplefield_null
(
&
row
->
tuple
[
12
]);
set_tuplefield_string
(
&
row
->
tuple
[
13
],
trig_args
);
set_tuplefield_string
(
&
row
->
tuple
[
13
],
trig_args
);
#if (ODBCVER >= 0x0300)
mylog
(
"defer_type = '%s'
, defer_type);
set_tuplefield_int2(&row->tuple[14], defer_type);
#endif /* ODBCVER >= 0x0300 */
#if (ODBCVER >= 0x0300)
mylog
(
"defer_type = '%s'
"
,
defer_type
);
set_tuplefield_int2
(
&
row
->
tuple
[
14
],
defer_type
);
#endif
/* ODBCVER >= 0x0300 */
QR_add_tuple
(
stmt
->
result
,
row
);
/* next primary/foreign key */
for (j = 0; j < 2; j++) {
pkey_ptr += strlen(pkey_ptr) + 1;
fkey_ptr += strlen(fkey_ptr) + 1;
for
(
j
=
0
;
j
<
2
;
j
++
)
{
pkey_ptr
+=
strlen
(
pkey_ptr
)
+
1
;
fkey_ptr
+=
strlen
(
fkey_ptr
)
+
1
;
}
}
...
...
src/interfaces/odbc/isql.h
View file @
01b5efa5
...
...
@@ -24,7 +24,9 @@ typedef signed short RETCODE;
# define SQL_API EXPORT CALLBACK
# endif
#ifndef ODBCVER
# define ODBCVER 0x0200
#endif
# define SQL_MAX_MESSAGE_LENGTH 512
# define SQL_MAX_DSN_LENGTH 32
...
...
src/interfaces/odbc/psqlodbc.h
View file @
01b5efa5
...
...
@@ -34,7 +34,9 @@ typedef double SDOUBLE;
typedef
UInt4
Oid
;
/* Driver stuff */
#ifndef ODBCVER
#define ODBCVER 0x0250
#endif
#define DRIVER_ODBC_VER "02.50"
#define DRIVERNAME "PostgreSQL ODBC"
...
...
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