JULEA
Functions
sql-generic-dql.c File Reference
#include <julea-config.h>
#include "sql-generic-internal.h"

Functions

gboolean _backend_schema_get (gpointer backend_data, gchar const *namespace, gchar const *name, bson_t *schema, GError **error)
 Retrieve the schema as bson document. More...
 
GHashTable * get_schema (gpointer backend_data, gchar const *namespace, gchar const *name, GError **error)
 Get the schema as a HashTable for internal usage. More...
 
gboolean sql_generic_schema_get (gpointer backend_data, gpointer _batch, gchar const *name, bson_t *schema, GError **error)
 
gboolean build_query_condition_part (gpointer backend_data, JSqlBatch *batch, bson_iter_t *iter, GString *sql, JDBSelectorMode mode, GArray *arr_types_in, GHashTable *variable_types, GError **error)
 Build the WHERE part of a SELECT statement from a selector. More...
 
gboolean bind_selector_query (gpointer backend_data, const gchar *namespace, bson_iter_t *iter, JSqlStatement *statement, GHashTable *schema, GError **error)
 Bind the variables in the WHERE part of a SELECT statement. More...
 
gboolean _backend_query_ids (gpointer backend_data, gpointer _batch, gchar const *name, bson_t const *selector, GArray **matches, GError **error)
 Query the IDs of rows that match a selector. More...
 
gboolean sql_generic_query (gpointer backend_data, gpointer _batch, gchar const *name, bson_t const *selector, gpointer *iterator, GError **error)
 
gboolean sql_generic_iterate (gpointer backend_data, gpointer _iterator, bson_t *query_result, GError **error)
 

Function Documentation

◆ _backend_query_ids()

gboolean _backend_query_ids ( gpointer  backend_data,
gpointer  _batch,
gchar const *  name,
bson_t const *  selector,
GArray **  matches,
GError **  error 
)

Query the IDs of rows that match a selector.

It is is used in the update and delete functions.

Todo:
Update and delete could be done by adding the selection part to the respective query, making this function unnecessary.
Parameters
backend_dataThe backend-specific information to open a connection.
_batchA JSqlBatch object.
nameThe schema name.
selectorA bson selector document sent by the client.
[out]matchesA GArray of the matched IDs.
[out]errorAn uninitialized GError* for error code passing.
Returns
gboolean TRUE on success, FALSE otherwise.
Todo:
check if caching this statement makes any difference with different databases

◆ _backend_schema_get()

gboolean _backend_schema_get ( gpointer  backend_data,
gchar const *  namespace,
gchar const *  name,
bson_t *  schema,
GError **  error 
)

Retrieve the schema as bson document.

This format is suitable for answering schema requests by clients.

Parameters
backend_dataThe backend-specific information to open a connection.
namespaceThe namespace of the schema.
nameThe schema name.
[in,out]schemaA bson document to be filled with schema information as a list of variable name and type pairs.
[out]errorAn uninitialized GError* for error code passing.
Returns
gboolean TRUE on success, FALSE otherwise.

◆ bind_selector_query()

gboolean bind_selector_query ( gpointer  backend_data,
const gchar *  namespace,
bson_iter_t *  iter,
JSqlStatement statement,
GHashTable *  schema,
GError **  error 
)

Bind the variables in the WHERE part of a SELECT statement.

Parameters
backend_dataThe backend-specific information to open a connection.
iterAn initialized iterator over the relevant part of the selector bson document. Should be retrieved the same way as for build_selector_query to ensure the same order of variables!
statementA JSqlStatement which
schemaThe database schema in hash table format.
Todo:
need to change this one for joins
Parameters
[out]errorAn uninitialized GError* for error code passing.
Returns
gboolean TRUE on success, FALSE otherwise.

◆ build_query_condition_part()

gboolean build_query_condition_part ( gpointer  backend_data,
JSqlBatch batch,
bson_iter_t *  iter,
GString *  sql,
JDBSelectorMode  mode,
GArray *  arr_types_in,
GHashTable *  schema,
GError **  error 
)

Build the WHERE part of a SELECT statement from a selector.

Parameters
backend_dataThe backend-specific information to open a connection.
iterAn initialized iterator over the relevant part of the selector bson document.
batchThe batch of the operation.
[in,out]sqlA GString to which the WHERE part of the query should be appended.
modeThe mode of the selector (i.e., AND or OR).
arr_types_inAn allocated GArray to which the found types will be appended.
schemaThe database schema in hash table format.
Todo:
need to change this one for joins
Parameters
[out]errorAn uninitialized GError* for error code passing.
Returns
gboolean TRUE on success, FALSE otherwise.

◆ get_schema()

GHashTable* get_schema ( gpointer  backend_data,
gchar const *  namespace,
gchar const *  name,
GError **  error 
)

Get the schema as a HashTable for internal usage.

Uses a transparent cache for schemas.

Todo:
Currently _backend_schema_get is called and the returned bson is converted to a GHashTable. A better way would be to use one common function for both so no conversion is neccessary.
Parameters
backend_dataThe backend-specific information to open a connection if needed.
namespaceThe namespace of the schema.
nameThe schema name.
[out]errorAn uninitialized GError* for error code passing.
Returns
GHashTable* A valid GHashTable pointer on success or NULL otherwise. The hash table should by freed using g_hash_table_unref (or by using g_autoptr).

◆ sql_generic_iterate()

gboolean sql_generic_iterate ( gpointer  backend_data,
gpointer  _iterator,
bson_t *  query_result,
GError **  error 
)
Todo:
Backend specific quotes need to be removed. There should be a better solution.

◆ sql_generic_query()

gboolean sql_generic_query ( gpointer  backend_data,
gpointer  _batch,
gchar const *  name,
bson_t const *  selector,
gpointer *  iterator,
GError **  error 
)

◆ sql_generic_schema_get()

gboolean sql_generic_schema_get ( gpointer  backend_data,
gpointer  _batch,
gchar const *  name,
bson_t *  schema,
GError **  error 
)