All datasources must provide functions to access their meta information. If the datasource is a database, such metainformation are the names of the tables, the columns, user rights, and so on. The results from a meta information query is represented as a Gda_Recordset. The problem is that most of the time the client is only interested in some part of the information. The client wants to query the data source about the indices for a table, not all indices for all tables. Therefore it is possible to pass constraints to the meta information query. But this is further complicated by he fact that each query might want to have different constraints. The following list will show which query types are implemented and which constraints are valid for each query. The constraints are passsed as name-value pairs. The name is an enum and the value is a string. The query function is a variadic function and the argument list must be closed with a enum value of 0.
The following table shows the most often used constraints and when to use them. Some schemas may require that you give a constraint.
Table 6-1. Main standard constraints' meaning
Constraint | Usage | Observations |
---|---|---|
GDA_Connection_OBJECT_CATALOG | Used to specify the Database | |
GDA_Connection_OBJECT_SCHEMA | Used to specify the owner | |
GDA_Connection_OBJECT_NAME | Used to specify the name of the object to query (table, ...) | |
GDA_Connection_EXTRA_INFO | Set it to have a more detailed answer from the provider | Set it to a non NULL string (e.g. "") |
The following table shows the "standard" schemas that must be supported by each GDA provider, although a specific provider may not support one of these. To test wether a schema is supported, see the gda_connection_supports() function.
Table 6-2. Standard Schema and supported constraints
Object Type | GDA identifier | Supported Constraints | Returned fields | Extra Info |
---|---|---|---|---|
Tables | GDA_Connection_GDCN_SCHEMA_TABLES | GDA_Connection_OBJECT_NAME, GDA_Connection_OBJECT_CATALOG, GDA_Connection_OBJECT_SCHEMA, GDA_Connection_EXTRA_INFO | name, comments | name, owner, comments, SQL definition |
Tables' parents (for providers that support tables inheritance) | GDA_Connection_GDCN_SCHEMA_TAB_PARENTS | GDA_Connection_OBJECT_NAME (required), GDA_Connection_OBJECT_CATALOG | name, order of inheritance | Not Supported |
Views | GDA_Connection_GDCN_SCHEMA_VIEWS | GDA_Connection_OBJECT_NAME, GDA_Connection_OBJECT_CATALOG, GDA_Connection_OBJECT_SCHEMA, GDA_Connection_EXTRA_INFO | name, comments | name, owner, comments, SQL definition |
Table (or view) columns | GDA_Connection_GDCN_SCHEMA_COLUMNS | GDA_Connection_OBJECT_NAME (required), GDA_Connection_OBJECT_CATALOG, GDA_Connection_OBJECT_SCHEMA, GDA_Connection_COLUMN_NAME | name, type, size, precision, nullable, is key, default value, comments | Not supported |
Sequences | GDA_Connection_GDCN_SCHEMA_SEQUENCES | GDA_Connection_OBJECT_NAME, GDA_Connection_OBJECT_CATALOG, GDA_Connection_OBJECT_SCHEMA, GDA_Connection_EXTRA_INFO | name, comments | name, owner, comments, SQL definition |
Procedures | GDA_Connection_GDCN_SCHEMA_PROCS | GDA_Connection_OBJECT_NAME, GDA_Connection_OBJECT_CATALOG, GDA_Connection_OBJECT_SCHEMA, GDA_Connection_EXTRA_INFO | name, object Id, comments | name, object Id, owner, comments, number of arguments, SQL definition |
Procedures' parameters | GDA_Connection_GDCN_SCHEMA_PROC_PARAMS | GDA_Connection_OBJECT_NAME (required) | Usage(in, out or inout), type | Not Supported |
Aggregates | GDA_Connection_GDCN_SCHEMA_AGGREGATES | GDA_Connection_OBJECT_NAME, GDA_Connection_OBJECT_CATALOG, GDA_Connection_OBJECT_SCHEMA, GDA_Connection_EXTRA_INFO | name, object Id, In type, comments | name, object Id, In type, owner, comments, SQL definition |
Types | GDA_Connection_GDCN_SCHEMA_PROV_TYPES | GDA_Connection_OBJECT_NAME, GDA_Connection_OBJECT_CATALOG, GDA_Connection_OBJECT_SCHEMA, GDA_Connection_EXTRA_INFO | name, owner, comments, Gda type, provider type | name, comments |
You must pay special attention to the constraints used (both in client applications and GDA providers), because it is required for providers to return an error if an invalid constraint is passed to the server. This is specially important, since there are schemas that may mean different things depending on the set of constraints used. As you can imagine, this could lead to the client receiving not-required data.