Subject help needed understanding the client API
Author Cosmin Apreutesei
Hi,

I need a little help to fix the Lua binding library in light of
http://tracker.firebirdsql.org/browse/CORE-2903 cummulated with my own
misunderstandings on the Firebird API.

My goal is to implement the generic

query(sql, params if any) -> results, if any

For this I need help completing the call sequence that would work for
any kind of query.

AFAIK, the generic call sequence for prepared statements is:

isc_dsql_alloc_statement2
isc_dsql_prepare
isc_dsql_describe
isc_dsql_describe_bind
isc_dsql_sql_info(isc_info_sql_stmt_type)
c) isc_dsql_execute + isc_dsql_fetch +
isc_dsql_free_statement(DSQL_close), for statements that return a
cursor
n) isc_dsql_execute alone, for statements that don't return a cursor
r) isc_dsql_execute2, for EXECUTE PROCEDURE RETURNING_VALUES and
INSERT RETURNING
isc_dsql_free_statement(DSQL_drop)

AFAIU, the only variable part of this call sequence is in choosing if
and how to fetch returned data (either do c), n), or r)), for which a
call to isc_dsql_sql_info(isc_info_sql_stmt_type) is needed
beforehand.

Q1: I need help correcting / completing the following decision table:

c isc_info_sql_stmt_select
? isc_info_sql_stmt_insert <-- can have RETURNING clause or not; what
about UPDATE OR INSERT ?
? isc_info_sql_stmt_update <-- can have RETURNING clause or not; what
about UPDATE OR INSERT ?
? isc_info_sql_stmt_delete <-- can have RETURNING clause or not
n isc_info_sql_stmt_ddl
? isc_info_sql_stmt_get_segment ???
? isc_info_sql_stmt_put_segment ???
? isc_info_sql_stmt_exec_procedure <-- can have RETURNING_VALUES
clause or not
n isc_info_sql_stmt_start_trans
n isc_info_sql_stmt_commit
n isc_info_sql_stmt_rollback
c isc_info_sql_stmt_select_for_upd
n isc_info_sql_stmt_set_generator
n isc_info_sql_stmt_savepoint

Q2: Is there anything else other than isc_info_sql_stmt_type that
influences the above call sequence?

Q3: Manual says isc_info_sql_stmt_type can return multiple entries (at
most two). In what cases does it return a second statement type and
what is its meaning?


Sorry for the long post. I'm forever grateful for any input on this.


Thanks,
Cosmin.