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

ecpg error on new lines #18

Closed
yonatan-blue opened this issue Dec 1, 2016 · 6 comments
Closed

ecpg error on new lines #18

yonatan-blue opened this issue Dec 1, 2016 · 6 comments

Comments

@yonatan-blue
Copy link

yonatan-blue commented Dec 1, 2016

on running:

from pgsanity.pgsanity import check_string
check_string(sql_command)

with a multi-line sql command I get:
*** Error in `ecpg': munmap_chunk(): invalid pointer: ***
I have found a workaround:

  sql_command = '\n'.join(
        filter(
            lambda line: line.strip() == "",
            sql_command.splitlines()
        )
    )

meaning I remove all empty lines.
I tried adding this snippet in: pgsanity.pgsanity.ecpg.check_syntax but it broke the tests:

  .............................F....F.FF..
======================================================================
FAIL: test_simple_failure (test.test_ecpg.TestEcpg)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/yonatan/github/pgsanity/test/test_ecpg.py", line 14, in test_simple_failure
    self.assertFalse(success)
AssertionError: True is not false

======================================================================
FAIL: test_check_invalid_string (test.test_pgsanity.TestPgSanity)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/yonatan/github/pgsanity/test/test_pgsanity.py", line 34, in test_check_invalid_string
    self.assertFalse(success)
AssertionError: True is not false

======================================================================
FAIL: test_check_invalid_file (test.test_pgsanity.TestPgSanityFiles)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/yonatan/github/pgsanity/test/test_pgsanity.py", line 56, in test_check_invalid_file
    self.assertNotEqual(status_code, 0)
AssertionError: 0 == 0

======================================================================
FAIL: test_check_missing_semi (test.test_pgsanity.TestPgSanityFiles)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/yonatan/github/pgsanity/test/test_pgsanity.py", line 65, in test_check_missing_semi
    self.assertNotEqual(status_code, 0)
AssertionError: 0 == 0

----------------------------------------------------------------------
Ran 40 tests in 0.020s

FAILED (failures=4)

how can I fix this?

@markdrago
Copy link
Owner

Can you provide a sql file that reproduces the problem?

@yonatan-blue
Copy link
Author

yonatan-blue commented Dec 4, 2016

@markdrago
following is the string I wanted to check, but, I tried reproducing and it only reproduce on python 3.4.3 and not on python 3.5.2.

CREATE OR REPLACE FUNCTION one_more_function_name(var_name TEXT) RETURNS INTEGER
AS $$
INSERT INTO another_function (var_name)
VALUES (var_name)
RETURNING id;
$$
LANGUAGE SQL;

CREATE OR REPLACE FUNCTION function_name(var_name TEXT) RETURNS INTEGER
AS $$
SELECT function_name(var_name)
$$
LANGUAGE SQL;

@markdrago
Copy link
Owner

I tried reproducing this and, as you said, it works in python 3.5.2. It also works with python 2.7.12. To be honest, I'm tempted to not make any changes. While I can't back it up, I think the munmap_chunk error is more indicative of a problem in ecpg than in pgsanity. I'd rather not work around it - especially if it works in the latest versions of python2 and python3.

Is it possible that your two tests are using different versions of ecpg as well? Was the python 3.4.3 test and the 3.5.2 test executed on the same machine with the same ecpg?

@yonatan-blue
Copy link
Author

yonatan-blue commented Dec 5, 2016

@markdrago yes, you are right:
I only got the error with:

ecpg (PostgreSQL 9.6.1) 4.12.0  # with python 3.4.3

and with:

ecpg (PostgreSQL 9.5.5) 4.11.0  # with python 3.5.2

I did not get the error.

  • notice that it is the newer version of ecpg that is supposedly broken :)

any how I'm good...

@markdrago thanks for your replay

@yonatan-blue
Copy link
Author

yonatan-blue commented Dec 5, 2016

tldr; check your ecpg version

@markdrago
Copy link
Owner

I'm running the same version of ecpg that gave you a problem:

ecpg (PostgreSQL 9.6.1) 4.12.0

I think we'll just hold tight for now and see if anyone else is able to reproduce.

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