Skip to content

Commit

Permalink
Merge pull request #12 from klando/for_guedes
Browse files Browse the repository at this point in the history
ldap_fdw segfaults with EXPLAIN ONLY
  • Loading branch information
guedes committed Aug 20, 2013
2 parents 3b312ba + 94c6e60 commit 0bae57c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ldap_fdw.c
Expand Up @@ -318,8 +318,11 @@ ldapEndForeignScan(ForeignScanState *node)
{
LdapFdwExecutionState *festate = (LdapFdwExecutionState *) node->fdw_state;

ldap_memfree(festate->ldap_entry);
ldap_unbind( festate->ldap_connection );
if (!EXEC_FLAG_EXPLAIN_ONLY)
{
ldap_memfree(festate->ldap_entry);
ldap_unbind( festate->ldap_connection );
}
}

/*
Expand Down
8 changes: 8 additions & 0 deletions test/expected/base.out
Expand Up @@ -92,3 +92,11 @@ SELECT * FROM ldap_john_smith;
|
(1 row)

EXPLAIN SELECT * FROM ldap_john_smith;
QUERY PLAN
-------------------------------------------------------------------------
Foreign Scan on ldap_john_smith (cost=10.00..510.00 rows=500 width=64)
Foreign Ldap: ldap
Foreign Ldap cost: 10
(3 rows)

2 changes: 2 additions & 0 deletions test/sql/base.sql
Expand Up @@ -31,3 +31,5 @@ ALTER FOREIGN TABLE ldap_john_smith
OPTIONS ( ADD attributes 'gidNumber,uidNumber,homeDirectory,nonExistant' );

SELECT * FROM ldap_john_smith;

EXPLAIN SELECT * FROM ldap_john_smith;

0 comments on commit 0bae57c

Please sign in to comment.