I encountered a template file in file-storage that uses the "include"
tag. In this particular instance, the included file is a .tcl file
(and its corresponding .adp template) that calls db_multirow. It
seems to me that when a call to a db api is embedded in an included
file, the QD is not involved. The actual code is more complicated,
so I constructed a simpler case to illustrate QD's behavior (or my
misunderstanding of it).
The main file, index.tcl, is very simple:
ad_return_template
So basically, it returns the template, index.adp. The template,
index.adp, is also very simple, because it only sources a single
file include.tcl:
<include src="include">
The include.tcl file contains a single call to db_string:
set a_date [db_string get_date "select sysdate() from dual"]
which is a very simple query (deliberately an oracle query). The
corresponding template, include.adp, contains:
Date today is @a_date@.
which prints out the actual date. So how do we port the above query,
contained in include.tcl, in postgresql? Well, I created the include-
postgresql.xql file, which contains:
<?xml version="1.0"?>
<queryset>
<rdbms><type>postgresql</type><version>7.1<
/version></rdbms>
<fullquery name="get_date">
<querytext>
select now() from dual
</querytext>
</fullquery>
</queryset>
However, loading the page index.tcl fails with an error that the
query cannot be executed. Looking at the logs, it seems that the QD
is not involved (or perhaps it is looking at the wrong file?). The
only way I can make the error disappear is to put the postgresql
query "select now() from dual" in the include.tcl file. The query in
include-postgresql.xql seems unused.
Is this the right behavior of the QD? Or am I misunderstanding
something here?