Skip to content

Improve output of results_eq and results_neq when number of columns or their types are different #255

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

Merged
merged 2 commits into from
Oct 10, 2021

Conversation

wolfgangwalther
Copy link
Contributor

@wolfgangwalther wolfgangwalther commented Jul 26, 2020

It's a pain to debug right now, when you're only getting Number of columns or their types differ between the queries, but no additional info.

This patch just uses GET STACKED DIAGNOSTICS to show the original error message, which has the differing types included.

Not sure whether #37 would still be needed with this change.

@theory
Copy link
Owner

theory commented Aug 1, 2020

The challenge is that pgTAP currently supports Postgres 9.1 or higher and GET STACKED DIAGNOSTICS was added in 9.2, I believe.

@wolfgangwalther
Copy link
Contributor Author

wolfgangwalther commented Aug 1, 2020

That's correct. That could be one of the reasons to drop support for 9.1, then... ;)

I can see that it makes sense to support older, discontinued versions of PG, as long as this doesn't block any improvements / development. But the last release for 9.1 has been in 2016...

In any case - if you still want to support 9.1, I can also put some conditionals in there to only enable this for 9.2+.

@theory
Copy link
Owner

theory commented Oct 24, 2020

Yes, let's keep 9.1 for at least one more release.

@wolfgangwalther
Copy link
Contributor Author

Added conditionals for pg 9.1. I tried the following at first:

IF pg_version_num() >= 90200 THEN
   EXECUTE 'GET STACKED DIAGNOSTICS err_msg = MESSAGE_TEXT';
END IF;

But that results in a syntax error for GET STACKED.... So I wrapped the whole CREATE FUNCTION in a DO block and inserted the GET STACKED DIAGNOSTICS ... only for >= 9.2.

I was not able to spin up a local pg 9.1 to test this - let's see what CI says.

@wolfgangwalther
Copy link
Contributor Author

So.. that works for pg 9.1. But, when I understand the output correctly, the update from 9.1 to 9.2 is broken. This must be because the function is not created again when upgrading. And since the function itself is not "dynamic" regarding the pg version, the pg9.1 function (without stacked diagnostics) is run on pg 9.2.

Any idea how to solve this?

@theory
Copy link
Owner

theory commented Oct 25, 2020

The way pgTAP has traditionally done this is to patch for older versions. So you'd leave GET STACKED DIAGNOSTICS in the source, but then add to compat/install-9.1.patch to remove it.

@wolfgangwalther wolfgangwalther force-pushed the results-eq-type-error branch 2 times, most recently from 3f3d22b to 2fc8c80 Compare October 25, 2020 20:29
@wolfgangwalther
Copy link
Contributor Author

So, I changed that and extended the patch. It does work the same way as before, but the update from pg 9.1 to 9.2 is still broken. And that makes sense, because running pg_upgrade does not add the GET STACKED DIAGNOSTICS back in. What am I missing to make this work?

@wolfgangwalther
Copy link
Contributor Author

Ah, I can answer this myself now. Those cases are explicitly excluded in test/test_MVU.sh. I added the relevant file there, I guess it should pass now.

@theory theory merged commit 986e3d4 into theory:master Oct 10, 2021
@wolfgangwalther wolfgangwalther deleted the results-eq-type-error branch November 1, 2021 20:32
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.

2 participants