diff --git a/build/script/aarch64_opengauss_list b/build/script/aarch64_opengauss_list index d01ef91ac..814d34976 100644 --- a/build/script/aarch64_opengauss_list +++ b/build/script/aarch64_opengauss_list @@ -835,6 +835,7 @@ ./lib/libpagecompression.so* ./lib/libdssapi.so ./lib/libdms.so +./lib/libodbc.so* ./include/postgresql/server/postgres_ext.h ./include/postgresql/server/pg_config_os.h diff --git a/build/script/opengauss_release_list_mini b/build/script/opengauss_release_list_mini index 435f57b52..58b21a021 100644 --- a/build/script/opengauss_release_list_mini +++ b/build/script/opengauss_release_list_mini @@ -884,6 +884,7 @@ ./lib/postgresql/latin2_and_win1250.so ./lib/postgresql/euc2004_sjis2004.so ./lib/libhll.so +./lib/libodbc.so* ./include/postgresql/server/postgres_ext.h ./include/postgresql/server/pg_config_os.h diff --git a/build/script/opengauss_release_list_ubuntu_single b/build/script/opengauss_release_list_ubuntu_single index 62c2733a6..fe76edc68 100644 --- a/build/script/opengauss_release_list_ubuntu_single +++ b/build/script/opengauss_release_list_ubuntu_single @@ -887,6 +887,7 @@ ./lib/postgresql/latin2_and_win1250.so ./lib/postgresql/euc2004_sjis2004.so ./lib/libhll.so +./lib/libodbc.so* ./include/postgresql/server/postgres_ext.h ./include/postgresql/server/pg_config_os.h diff --git a/build/script/x86_64_opengauss_list b/build/script/x86_64_opengauss_list index 2c7a57df3..014186a34 100644 --- a/build/script/x86_64_opengauss_list +++ b/build/script/x86_64_opengauss_list @@ -832,6 +832,7 @@ ./lib/libpagecompression.so* ./lib/libdssapi.so ./lib/libdms.so +./lib/libodbc.so* ./include/postgresql/server/postgres_ext.h ./include/postgresql/server/pg_config_os.h diff --git a/contrib/dblink/dblink.cpp b/contrib/dblink/dblink.cpp index 85c205c61..a1795cb64 100644 --- a/contrib/dblink/dblink.cpp +++ b/contrib/dblink/dblink.cpp @@ -106,6 +106,7 @@ static bool UseODBCLinker(char* connstr); #define REMOTE_CONN_HASH (get_session_context()->remoteConnHash) /* initial number of connection hashes */ #define NUMCONN 16 +#define NAX_ERR_MSG_LEN 1000 #define MAX_BUF_LEN 100000 #define MAX_DRIVERNAME_LEN 50 #define DBLINK_NOTIFY_COLS 3 @@ -559,6 +560,9 @@ ODBCLinker::ODBCLinker(char* connstr_or_name) } LinkInfo linfo; + linfo.drivername = NULL; + linfo.password = NULL; + linfo.username = NULL; int len = strlen(connstr_or_name); GetDrivername(connstr_or_name, &linfo); /* atuo commit is the default value */ @@ -568,11 +572,13 @@ ODBCLinker::ODBCLinker(char* connstr_or_name) securec_check(rc, "\0", "\0"); if ((error != SQL_SUCCESS) && (error != SQL_SUCCESS_WITH_INFO)) { + SQLCHAR sqlcode[NAX_ERR_MSG_LEN]; + SQLGetDiagField(SQL_HANDLE_DBC, this->connHandle, 1, SQL_DIAG_MESSAGE_TEXT, &sqlcode, NAX_ERR_MSG_LEN, NULL); SQLFreeHandle(SQL_HANDLE_DBC, this->connHandle); SQLFreeHandle(SQL_HANDLE_ENV, this->envHandle); ereport(ERROR, (errcode(ERRCODE_CONNECTION_FAILURE), - errmsg("Error SQLConnect"))); + errmsg("Error SQLConnect\n%s", sqlcode))); } } @@ -629,9 +635,8 @@ char* ODBCLinker::errorMsg() if (this->stmt == NULL) { return NULL; } - int msgLen = 100; - char* msg = (char*)palloc(sizeof(char) * msgLen); - SQLGetDiagRec(SQL_HANDLE_STMT, this->stmt, 1, NULL, NULL, (SQLCHAR*)msg, 100 ,NULL); + char* msg = (char*)palloc(sizeof(char) * NAX_ERR_MSG_LEN); + SQLGetDiagRec(SQL_HANDLE_STMT, this->stmt, 1, NULL, NULL, (SQLCHAR*)msg, NAX_ERR_MSG_LEN, NULL); return msg; }