This file is indexed.

/usr/include/libgda-5.0/libgda/virtual/gda-vconnection-data-model.h is in libgda-5.0-dev 5.2.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*
 * Copyright (C) 2007 - 2011 Vivien Malerba <malerba@gnome-db.org>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 */

#ifndef __GDA_VCONNECTION_DATA_MODEL_H__
#define __GDA_VCONNECTION_DATA_MODEL_H__

#include <virtual/gda-virtual-connection.h>
#include <sql-parser/gda-statement-struct-parts.h>

#define GDA_TYPE_VCONNECTION_DATA_MODEL            (gda_vconnection_data_model_get_type())
#define GDA_VCONNECTION_DATA_MODEL(obj)            (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_VCONNECTION_DATA_MODEL, GdaVconnectionDataModel))
#define GDA_VCONNECTION_DATA_MODEL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_VCONNECTION_DATA_MODEL, GdaVconnectionDataModelClass))
#define GDA_IS_VCONNECTION_DATA_MODEL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE (obj, GDA_TYPE_VCONNECTION_DATA_MODEL))
#define GDA_IS_VCONNECTION_DATA_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDA_TYPE_VCONNECTION_DATA_MODEL))

G_BEGIN_DECLS

typedef struct _GdaVconnectionDataModel      GdaVconnectionDataModel;
typedef struct _GdaVconnectionDataModelClass GdaVconnectionDataModelClass;
typedef struct _GdaVconnectionDataModelPrivate GdaVconnectionDataModelPrivate;
typedef struct _GdaVconnectionDataModelSpec  GdaVconnectionDataModelSpec;
typedef struct _GdaVconnectionDataModelFilter GdaVconnectionDataModelFilter;

/**
 * GdaVconnectionDataModelCreateColumnsFunc:
 * @Param1: a pointer to a #GdaVconnectionDataModelSpec structure
 * @Param2: a place to store errors, or %NULL
 * @Returns: (element-type GdaColumn) (transfer full): a new list of #GdaColumn objects
 *
 * Function called to create the virtual table's columns, as #GdaColumn objects.
 */
typedef GList *(*GdaVconnectionDataModelCreateColumnsFunc) (GdaVconnectionDataModelSpec *, GError **);

/**
 * GdaVconnectionDataModelCreateModelFunc:
 * @Param1: a pointer to a #GdaVconnectionDataModelSpec structure
 * @Returns: (transfer full): a new #GdaDataModel
 *
 * Function called to create a #GdaDataModel object, called when a virtual table's data need to
 * be accessed, and when optimization is not handled.
 */
typedef GdaDataModel *(*GdaVconnectionDataModelCreateModelFunc) (GdaVconnectionDataModelSpec *);

/**
 * GdaVconnectionDataModelFunc:
 * @Param1: (allow-none): a pointer to a #GdaDataModel
 * @Param2: the name of the table represented by @Param1
 * @Param3: a data pointer, passed as last ergument to gda_vconnection_data_model_foreach()
 *
 * This function is called for every #GdaDataModel representing a table in a #GdaVconnectionDataModel
 * connection, when using the gda_vconnection_data_model_foreach() method.
 */
typedef void (*GdaVconnectionDataModelFunc) (GdaDataModel *, const gchar *, gpointer );

/**
 * GdaVconnectionDataModelFilter:
 *
 * This structure contains data which should be analysed to produce a data model (used as data 
 * for a virtual table) when a #GdaVconnectionDataModelCreateFModelFunc is called. The structure
 * contains an input part (which should not be modified) and and output part (it is
 * closely mapped with SQLite's sqlite3_index_info type).
 *
 * A pointer to this structure is passed to the #GdaVconnectionDataModelParseFilterFunc function
 * and the function has to modify the variables in the output part (marked as *Outputs*).
 *
 * The @idxNum and @idxPointer are passed to the #GdaVconnectionDataModelCreateFModelFunc function call
 * and they represent nothing specific except that the GdaVconnectionDataModelParseFilterFunc and
 * GdaVconnectionDataModelCreateFModelFunc functions need to agree on their meaning.
 *
 * See the gda-vconnection-hub.c file for an usage example.
 */
struct _GdaVconnectionDataModelFilter {
	/* Inputs */
	int nConstraint; /* Number of entries in aConstraint */
	struct GdaVirtualConstraint {
		int iColumn;       /* Column on left-hand side of constraint */
		GdaSqlOperatorType op;  /* Constraint operator, among _EQ, _LT, _LEQ, _GT, _GEQ, _REGEXP */
	} *aConstraint;            /* Table of WHERE clause constraints */
	int nOrderBy;              /* Number of terms in the ORDER BY clause */
	struct GdaVirtualOrderby {
		int iColumn;       /* Column number */
		gboolean desc;     /* TRUE for DESC.  FALSE for ASC. */
	} *aOrderBy;               /* The ORDER BY clause */

	/* Outputs */
	struct GdaVirtualConstraintUsage {
		int argvIndex;     /* if >0, constraint is part of argv to xFilter */
		gboolean omit;     /* Do not code a test for this constraint if TRUE */
	} *aConstraintUsage;
	int idxNum;                /* Number used to identify the index */
	gpointer idxPointer;       /* Pointer used to identify the index */
	gboolean orderByConsumed;  /* TRUE if output is already ordered */
	double estimatedCost;      /* Estimated cost of using this index */
};

/**
 * GdaVconnectionDataModelParseFilterFunc:
 * @Param1: a pointer to a #GdaVconnectionDataModelSpec structure
 * @Param2: a pointer to a #GdaVconnectionDataModelFilter structure
 *
 * This function actually analyses the proposed optimization and modified @Param2 to tell the database
 * engine how (if applicable) it implements the optimization.
 */
typedef void (*GdaVconnectionDataModelParseFilterFunc) (GdaVconnectionDataModelSpec *, GdaVconnectionDataModelFilter *); 

/**
 * GdaVconnectionDataModelCreateFModelFunc:
 * @Param1: a pointer to a #GdaVconnectionDataModelSpec structure
 * @Param2: the index number chosen to actually execute the optimization (from #GdaVconnectionDataModelFilter's #idxNum attribute)
 * @Param3: corresponds to the #GdaVconnectionDataModelFilter's #idxPointer attribute
 * @Param4: size of @Param5
 * @Param5: an array of #GValue, as specified by the #GdaVconnectionDataModelFilter's #aConstraintUsage's #argvIndex value
 * @Returns: (transfer full): a new #GdaDataModel
 *
 * Function called to create a #GdaDataModel object, called when a virtual table's data need to
 * be accessed, and when optimization is handled.
 */
typedef GdaDataModel *(*GdaVconnectionDataModelCreateFModelFunc) (GdaVconnectionDataModelSpec *, int, const char *, int, GValue **);

/**
 * GdaVconnectionDataModelSpec:
 * @data_model: (allow-none): a #GdaDataModel, or %NULL
 * @create_columns_func: (allow-none): a pointer to a #GdaVconnectionDataModelCreateColumnsFunc function, or %NULL
 * @create_model_func: (allow-none): a pointer to a #GdaVconnectionDataModelCreateModelFunc function, or %NULL
 * @create_filter_func: (allow-none): a pointer to a #GdaVconnectionDataModelParseFilterFunc function, or %NULL
 * @create_filtered_model_func: (allow-none): a pointer to a #GdaVconnectionDataModelCreateFModelFunc function, or %NULL
 *
 * This structure holds all the information supplied to declare a virtual table using
 * gda_vconnection_data_model_add(). You don't need to provider pointers for all the functions and
 * for @data_model, but the following rules have to be respected:
 * <itemizedlist>
 *  <listitem><para>@data_model is not %NULL and all the function pointers are %NULL: this is the situation
 *   when the virtual table's contents is defined once by @data_model</para></listitem>
 *  <listitem><para>@data_model is %NULL and @create_columns_func is not %NULL:
 *     <itemizedlist>
 *        <listitem><para>@create_filtered_model_func is not %NULL: this is the situation where the
 *                        virtual table's associated data model handles filter optimizations.
 *                        @create_model_func is ignored in this case.
 *        </para></listitem>
 *        <listitem><para>@create_model_func is not %NULL: this is the situation where the
 *                        virtual table's associated data model does not handle filter optimizations
 *        </para></listitem>
 *     </itemizedlist>
 *  </para></listitem>
 * </itemizedlist>
 *
 * Note that if specifying a @create_filtered_model_func, you should also specifiy a @create_filter_func
 * function which is actually responsible for analysing the optimization.
 */
struct _GdaVconnectionDataModelSpec {
	GdaDataModel                             *data_model;
	GdaVconnectionDataModelCreateColumnsFunc  create_columns_func;
	GdaVconnectionDataModelCreateModelFunc    create_model_func;

	GdaVconnectionDataModelParseFilterFunc    create_filter_func;
	GdaVconnectionDataModelCreateFModelFunc   create_filtered_model_func;
};
#define GDA_VCONNECTION_DATA_MODEL_SPEC(x) ((GdaVconnectionDataModelSpec*)(x))

struct _GdaVconnectionDataModel {
	GdaVirtualConnection            connection;
	GdaVconnectionDataModelPrivate *priv;
};

struct _GdaVconnectionDataModelClass {
	GdaVirtualConnectionClass       parent_class;

	void                          (*vtable_created) (GdaVconnectionDataModel *cnc,
							  const gchar *table_name);
	void                          (*vtable_dropped) (GdaVconnectionDataModel *cnc,
							    const gchar *table_name);

	/*< private >*/
	/* Padding for future expansion */
	void (*_gda_reserved1) (void);
	void (*_gda_reserved2) (void);
};

/**
 * SECTION:gda-vconnection-data-model
 * @short_description: Virtual connection based on a list of GdaDataModel
 * @title: GdaVconnectionDataModel
 * @stability: Stable
 * @see_also: The #GdaVproviderDataModel provider to use to create such connection objects.
 *
 * The #GdaVconnectionDataModel is a virtual connection in which #GdaDataModel data models can be added
 * or removed, each representing a table in the connection, the gda_vconnection_data_model_add_model()
 * and gda_vconnection_data_model_remove() methods.
 *
 * Furthermore it is possible to declare tables without any associated data model yet,
 * the real data model being automatically created when the
 * table's data is needed. This allows more dynamic table's contents and filtering optimizations.
 * See the gda_vconnection_data_model_add() and gda_vconnection_data_model_remove() methods. The
 * filtering optimizations are based on SQLite's virtual table optimisations see
 * <ulink url="http://www.sqlite.org/cvstrac/wiki?p=VirtualTableBestIndexMethod">SQLite's documentation</ulink>
 * for some background information.
 */

GType               gda_vconnection_data_model_get_type  (void) G_GNUC_CONST;

gboolean            gda_vconnection_data_model_add       (GdaVconnectionDataModel *cnc, GdaVconnectionDataModelSpec *spec, 
							  GDestroyNotify spec_free_func,
							  const gchar *table_name, GError **error);
gboolean            gda_vconnection_data_model_add_model (GdaVconnectionDataModel *cnc, 
							  GdaDataModel *model, const gchar *table_name, GError **error);
gboolean            gda_vconnection_data_model_remove    (GdaVconnectionDataModel *cnc, const gchar *table_name, GError **error);

GdaVconnectionDataModelSpec *gda_vconnection_data_model_get (GdaVconnectionDataModel *cnc, const gchar *table_name);
const gchar        *gda_vconnection_data_model_get_table_name (GdaVconnectionDataModel *cnc, GdaDataModel *model);
GdaDataModel       *gda_vconnection_data_model_get_model (GdaVconnectionDataModel *cnc, const gchar *table_name);

void                gda_vconnection_data_model_foreach   (GdaVconnectionDataModel *cnc, 
							  GdaVconnectionDataModelFunc func, gpointer data);

G_END_DECLS

#endif