On Wed, Mar 25, 2009 at 5:10 PM, Stephen Deasey <[email protected]> wrote:
> On Wed, Mar 25, 2009 at 10:56 PM, Ian Harding <[email protected]> wrote:
>> I am in a situation where I'd like to be able to set the search_path
>> on each page request. In AOLServer I would have just made a db handle
>> getter function that would call ns_db gethandle, issue a quick SET
>> command, and pass the handle back to the caller.
<snip>
> Alternatively, you could set the max number of handles to 0, in which
> case the driver switches to handle-per-thread mode (See docs). In
> this case, when each command 'gets' a handle it will always get the
> same one, as it is never actually returned to the pool but cached for
> the thread.
OK, so my maxhandles is 0, per the default, so I should always get the
same handle in repeated calls. I'm apparently not because when I
issue
dbi_dml {set search_path to test,public}
dbi_rows {select * from tableintestbutnotpublic}
I get an error stating that the table does not exist.
Here's my postgres log
LOG: statement: set client_encoding to 'UTF8'
LOG: execute dbipg_0: set session client_encoding = 'UTF8'
LOG: execute dbipg_1: set session timezone = 'UTC'
LOG: execute dbipg_2: set session datestyle = 'ISO'
LOG: execute dbipg_3: set search_path to test,public
ERROR: relation "classification" does not exist
STATEMENT: SELECT classification
FROM classification
ORDER BY classification
but it does exist...
test=# \dt test.classification
List of relations
Schema | Name | Type | Owner
--------+----------------+-------+-------
test | classification | table | user
(1 row)
So I wrote a test that goes like this
if {[catch {
catch {dbi_dml {drop table test}}
catch {dbi_dml {drop schema test cascade}}
dbi_dml {
create schema test
}
dbi_dml {
create table test (
a integer not null,
b varchar not null,
c bytea,
test varchar
)
}
dbi_dml {insert into test (a, b, test) values (1, 'x', 'test1')}
dbi_dml {insert into test (a, b, test) values (2, 'y', 'test2')}
} err]} {
ns_log error $err
} else {
testConstraint table true
}
test schema-1 {bad search path} -constraints table -body {
dbi_dml {set search_path to test}
dbi_rows {select * from test}
} -returnCodes error -result {relation "test" does not exist}
test schema-2 {bad search path same thread} -constraints table -body {
dbi_rows {select * from test}
} -returnCodes error -result {relation "test" does not exist}
test schema-3 {good search path} -constraints table -body {
dbi_dml {set search_path to public}
dbi_rows {select * from test where a = 99}
} -result {}
Which passes when run with make test.
So, what could be my problem here? My config file is being used, and
it does say maxhandles=0...
ns_section "ns/server/${server}/module/dbpg"
ns_param default true
ns_param maxhandles 0
ns_param timeout 10
- Ian
------------------------------------------------------------------------------
_______________________________________________
naviserver-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/naviserver-devel