@@ -2071,12 +2071,25 @@ SQLRETURN EsSQLSetConnectAttrW(
2071
2071
return SQL_SUCCESS ;
2072
2072
}
2073
2073
2074
- #if 0
2075
- static BOOL get_current_catalog (esodbc_dbc_st * dbc )
2074
+ /* writes into 'dest', of size 'room', the current catalog of 'dbc'.
2075
+ * returns negative on error, or the char count written otherwise */
2076
+ static SQLSMALLINT get_current_catalog (esodbc_dbc_st * dbc , SQLWCHAR * dest ,
2077
+ SQLSMALLINT room )
2076
2078
{
2077
- FIXME ;
2079
+ SQLSMALLINT used ;
2080
+ SQLWCHAR * catalog = MK_WPTR ("my_current_catalog" ); // FIXME
2081
+
2082
+ //
2083
+ // TODO: use the new SYS CATALOGS query
2084
+ //
2085
+
2086
+ DBGH (dbc , "current catalog: `" LWPD "`." , catalog );
2087
+ if (! SQL_SUCCEEDED (write_wptr (& dbc -> hdr .diag , dest , catalog , room ,
2088
+ & used ))) {
2089
+ return -1 ;
2090
+ }
2091
+ return used ;
2078
2092
}
2079
- #endif //0
2080
2093
2081
2094
SQLRETURN EsSQLGetConnectAttrW (
2082
2095
SQLHDBC ConnectionHandle ,
@@ -2086,9 +2099,7 @@ SQLRETURN EsSQLGetConnectAttrW(
2086
2099
_Out_opt_ SQLINTEGER * StringLengthPtr )
2087
2100
{
2088
2101
esodbc_dbc_st * dbc = DBCH (ConnectionHandle );
2089
- SQLRETURN ret ;
2090
2102
SQLSMALLINT used ;
2091
- // SQLWCHAR *val;
2092
2103
2093
2104
switch (Attribute ) {
2094
2105
/* https://docs.microsoft.com/en-us/sql/odbc/reference/develop-app/automatic-population-of-the-ipd */
@@ -2103,30 +2114,17 @@ SQLRETURN EsSQLGetConnectAttrW(
2103
2114
2104
2115
/* "the name of the catalog to be used by the data source" */
2105
2116
case SQL_ATTR_CURRENT_CATALOG :
2106
- DBGH (dbc , "requested: catalog name (@0x%p)." , dbc -> catalog );
2107
- #if 0
2117
+ DBGH (dbc , "requested: catalog name." );
2108
2118
if (! dbc -> es_types ) {
2109
2119
ERRH (dbc , "no connection active." );
2110
- /* TODO: check connection state and correct state */
2111
2120
RET_HDIAGS (dbc , SQL_STATE_08003 );
2112
- } else if (! get_current_catalog (dbc )) {
2121
+ } else if ((used = get_current_catalog (dbc , (SQLWCHAR * )ValuePtr ,
2122
+ (SQLSMALLINT )BufferLength )) < 0 ) {
2113
2123
ERRH (dbc , "failed to get current catalog." );
2114
- RET_STATE (dbc , dbc -> hdr .diag .state );
2124
+ RET_STATE (dbc -> hdr .diag .state );
2115
2125
}
2116
- #endif //0
2117
- #if 0
2118
- val = dbc -> catalog ? dbc -> catalog : MK_WPTR ("null" );
2119
- * StringLengthPtr = wcslen (* (SQLWCHAR * * )ValuePtr );
2120
- * StringLengthPtr *= sizeof (SQLWCHAR );
2121
- * (SQLWCHAR * * )ValuePtr = val ;
2122
- #else //0
2123
- // FIXME;
2124
- ret = write_wptr (& dbc -> hdr .diag , (SQLWCHAR * )ValuePtr ,
2125
- MK_WPTR ("NulL" ), (SQLSMALLINT )BufferLength , & used );
2126
2126
if (StringLengthPtr );
2127
2127
* StringLengthPtr = (SQLINTEGER )used ;
2128
- return ret ;
2129
- #endif //0
2130
2128
break ;
2131
2129
2132
2130
case SQL_ATTR_METADATA_ID :
0 commit comments