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

fix MSVC2015 build & mssql instance name support & fix fails on IMPORT FOREIGN SCHEMA... #162

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

4321ip
Copy link

@4321ip 4321ip commented Apr 2, 2018

some fixes

@jenkins-juliogonzalez
Copy link
Member

Can one of the admins verify this patch?

@jenkins-juliogonzalez
Copy link
Member

Test PASSed.

@juliogonzalez
Copy link
Member

@4321ip maybe you can add a new test to check the queries that were crashing?

@jenkins-juliogonzalez
Copy link
Member

Test PASSed.

@GeoffMontee
Copy link
Collaborator

Hi @4321ip,

Thanks for the PR!

Unfortunately, I don't think that I can accept the PR, as it currently is. Here are some comments:

  • 8b76c8e has some code commented out. It is unclear to me why this code is commented out. I am also not entirely sure that I agree with the assertion in the comment that DEFAULT clauses are "useless". I suspect that DEFAULT clauses might be important when/if tds_fdw supports INSERT.

  • 418b140 also has some code commented out. If you move a function call to a new location, it would probably be better to delete the redundant instance of the code, rather than just commenting it out. However, I am unsure why this change is necessary. Can you please provide an example of when the old code had problems, so we know what problem the new code fixes? It looks like the problem involved a case where relname == NULL. When would that happen in this context? Shouldn't all queries handled by tds_fdw involve a foreign table?

  • b6b8665 also has code commented out. I'm also not sure if the change is a good one, because it forces tds_fdw to use local statistics by default, and I'm not actually sure how well ANALYZE works with tds_fdw's foreign tables, so I'm not entirely confident that the local statistics are meaningful. I should also add that if you are using MS SQL Server, then this change isn't even necessary because there is already a solution to the problem of the query running multiple times--set row_estimate_method=showplan_all. See the documentation for more information - https://github.com/tds-fdw/tds_fdw/blob/master/ForeignTableCreation.md

  • 821c6cb - It is not clear to me why the case of column names should be ignored. I also think the assertion that "local_name always in lowcase" is false. People can create upper or mixed-case column names by enclosing the names in quotes when they create the table. Am I misunderstanding something?

  • cd56e0a also has code commented out. It looks like you added include directives for 2 FreeTDS headers, but then commented out the new directives? I like the added support for an "instance" name. It also seems to include a fix for an unrelated crash? What crash did this fix?

Please let me know if you have any questions.

Thanks again for the PR!

@4321ip
Copy link
Author

4321ip commented Apr 3, 2018 via email

@4321ip 4321ip changed the title fix MSVC2015 build & fix fails on IMPORT FOREIGN SCHEMA... fix MSVC2015 build & mssql instance name support & fix fails on IMPORT FOREIGN SCHEMA... Apr 3, 2018
@jenkins-juliogonzalez
Copy link
Member

Test FAILed.

@@ -1407,7 +1414,8 @@ void tdsGetColumnMetadata(ForeignScanState *node, TdsFdwOptionSet *option_set)
(errmsg("tds_fdw: Comparing retrieved column name to the following local column name: %s", local_name)
));

if (strncmp(local_name, column->name, NAMEDATALEN) == 0)
//! \PPV local_name always in lowcase. But column->name's register defined in sql server. so you should ignore case
if (strnicmp(local_name, column->name, NAMEDATALEN) == 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this is crashing tds_fdw on loading: https://jenkins.juliogonzalez.es/job/tds_fdw-build-pr/44/DISTRO=ubuntu14.04,PG_VER=9.2,label=docker/console

Could it be that strnicmp is not part of the standard library and MS stuff only?

@juliogonzalez
Copy link
Member

@4321ip, can we get this PR fixed? If it helps with the Windows support, it could be useful.

But for that we need:

  • Solving the conflicts
  • Passing the tests
  • Approval by Geoff.

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

Successfully merging this pull request may close these issues.

4 participants