Problem Changing search_path in pgTAP tests

From: Scott Sturdivant <scott(at)suran(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Problem Changing search_path in pgTAP tests
Date: 2010-04-30 13:53:37
Message-ID: 1B086912-1690-4302-AB6C-8A2EF3193EEA@suran.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi. I am running into a problem when trying to run pgTAP tests. Basically, there are two functions with the same name in different schemas, and I'm trying to get different versions at different times by modifying the search_path. However, there seems to be a case where postgres is caching the functions, causing it to find the wrong function after the search path has been changed. Here is a more detailed description -

There are two pgTAP tests, A and B. They both run the same function in the public schema, C. C runs a function D. There are two versions of D (D1 and D2), in two different schemas (S1 and S2).

Test A sets the search path to include S1, but not S2, so when C runs, it should run D1, not D2. This works correctly.
Test B sets the search path to include S2, but not S1, so when C runs, it should run D2, not D1. In this case, D1 is still what gets run. A print statement confirms that D1 is being run, and that, in the function D1, the search path includes S2, but not S1.

It will work correctly if A and B just attempt to run D directly. This problem only happens when A and B run C, which in turn runs D.

This problem also won't occur if some function runs D, changes the search path, and runs D again.

I have a small database that will reproduce this issue. It contains 7 functions (and the pgTAP functions) - some are there to reproduce the issue, others are there to show control cases where the problem doesn't happen. I won't post it here in case attachements don't come through correctly, but if anyone is interested please let me know and I will be happy to email it directly to you.

We are running on Postgres 8.4.1 on Mac.

Also, for anyone not familiar with pgTAP, here is the website - http://pgtap.projects.postgresql.org/

- Scott Sturdivant

Browse pgsql-general by date

  From Date Subject
Next Message Ing. Yunior Mesa Reyes 2010-04-30 14:10:10 Nuevo sobre PGday Latinoamericano 2011...
Previous Message Ognjen Blagojevic 2010-04-30 10:11:12 Re: Java Memory Issue while Loading Postgres library