Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tds_err_handler function #83

Open
lorenati opened this issue Jul 14, 2016 · 3 comments
Open

tds_err_handler function #83

lorenati opened this issue Jul 14, 2016 · 3 comments

Comments

@lorenati
Copy link

lorenati commented Jul 14, 2016

I'm using tds_fdw in windows 7 x64, I think I have an issue with this function inside tds_err_handler

ereport(ERROR,
            (errcode(ERRCODE_FDW_UNABLE_TO_CREATE_EXECUTION),
            errmsg("DB-Library error: DB #: %i, DB Msg: %s, OS #: %i, OS Msg: %s, Level: %i",
            dberr, dberrstr, oserr, oserrstr, severity)
            )); 

I did a little debug and the function _dblib_handle_info_message located in dbutil.c calls this tds_err_handler function and puts NULL in the oserrstr variable. If I do something that can call this function, like calling a foreign table that doesn't exists (in sql server side) the postgres service crashes.

I modified the function like this:

ereport(ERROR,
            (errcode(ERRCODE_FDW_UNABLE_TO_CREATE_EXECUTION),
            errmsg("DB-Library error: DB #: %i, DB Msg: %s, OS #: %i, Level: %i",
            dberr, dberrstr, oserr, severity)
            ));

So I don't include the oserrstr variable and postgres just throws the error but the service is safe. I'm not sure how can this null value can cause the service crash, do you have any suggestions?

GeoffMontee added a commit that referenced this issue Jul 14, 2016
@GeoffMontee
Copy link
Collaborator

Thanks for the bug report!

Can you please see if this is fixed for you in the latest commit? b770b2d

@lorenati
Copy link
Author

Yes, with the latest commit the problem is fixed

Thank you

@GeoffMontee
Copy link
Collaborator

Awesome! I'm glad to hear that it's not crashing for you anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants