I was leaning towards using the current schema at the prepared time because I am hoping to do all the collation validation at the compile phase rather than the execute phase. Picking up the schema at the prepared time will help me enable that.
Let me look at your following mail a little bit more to see if I need to change my mind :)
On 4/3/07, Army <email@example.com> wrote:
> Since a parameter maker does not have a "defined" schema, does "current
> schema" mean the schema when the statement is prepared, or the schema
> when it is executed?
> For example I can do the following in JDBC:
> // Default schema ("APP").
> PreparedStatement ps = conn.prepareStatement(
> "select tablename, tabletype from sys.systables where tablename = ?");
> If "current schema" means the "schema when the statement is *prepared*"
> then both of the above statements would fail (because there's no CAST on
> the syscol). That consistency would probably be a good thing (less
> confusing for users).
On the other hand, if the statement is changed to:
// Default schema APP.
PreparedStatement ps = conn.prepareStatement(
"select tablename, tabletype from sys.systables where " +
"CAST (tablename as varchar(128)) = ?");
then it might be better to take "current schema" to mean the time of
*execution.* That way the the above statement will run correctly regardless of
the current schema. If "current schema" was determined at compile time, the
above statement would only work if "current schema" was a non-system schema.
Since I think we are going to encourage users to CAST system columns when doing
comparisons (at least that's what I gathered from the various discussion
threads), maybe it would be better to take the "current schema" for a parameter
marker at execution time, after all...?