gda-statement-struct-decl

gda-statement-struct-decl

Object Hierarchy

    GBoxed
    ├── GdaSqlAnyPart
    ├── GdaSqlStatement
    ╰── GdaSqlStatementContentsInfo
    GEnum
    ├── GdaSqlAnyPartType
    ├── GdaSqlError
    ╰── GdaSqlStatementType

Description

Functions

gda_sql_error_quark ()

GQuark
gda_sql_error_quark (void);

gda_sql_any_part_set_parent()

#define             gda_sql_any_part_set_parent(a,p)

GdaSqlForeachFunc ()

gboolean
(*GdaSqlForeachFunc) (GdaSqlAnyPart *part,
                      gpointer data,
                      GError **error);

Specifies the type of functions passed to gda_sql_any_part_foreach().

Parameters

part

the current GdaSqlAnyPart node

 

data

user data passed to gda_sql_any_part_foreach().

 

error

pointer to a place to store errors

 

Returns

FALSE if the gda_sql_any_part_foreach() should stop at this point and fail


gda_sql_any_part_foreach ()

gboolean
gda_sql_any_part_foreach (GdaSqlAnyPart *node,
                          GdaSqlForeachFunc func,
                          gpointer data,
                          GError **error);

Calls a function for each element of a GdaSqlAnyPart node

Parameters

node

the stat node

 

func

function to call for each sub node.

[scope call]

data

data to pass to func each time it is called.

[closure]

error

a place to store errors, or NULL (is also passed to func )

 

Returns

TRUE if func has been called for any sub node of node and always returned TRUE, or FALSE otherwise.


gda_sql_any_part_check_structure ()

gboolean
gda_sql_any_part_check_structure (GdaSqlAnyPart *node,
                                  GError **error);

Checks for any error in node 's structure to make sure it is valid. This is the same as gda_sql_statement_check_structure() but for individual GdaSqlAnyPart parts. This function is mainly for database provider's implementations

Parameters

node

a GdaSqlAnyPart pointer

 

error

a place to store errors, or NULL

 

Returns

TRUE if no error occurred

Types and Values

GDA_SQL_ERROR

#define GDA_SQL_ERROR gda_sql_error_quark ()

enum GdaSqlError

Members

GDA_SQL_STRUCTURE_CONTENTS_ERROR

   

GDA_SQL_MALFORMED_IDENTIFIER_ERROR

   

GDA_SQL_MISSING_IDENTIFIER_ERROR

   

GDA_SQL_VALIDATION_ERROR

   

GdaSqlErrorType

typedef GdaSqlError GdaSqlErrorType;

enum GdaSqlStatementType

Known types of statements

Members

GDA_SQL_STATEMENT_SELECT

a SELECT statement

 

GDA_SQL_STATEMENT_INSERT

an INSERT statement

 

GDA_SQL_STATEMENT_UPDATE

an UPDATE statement

 

GDA_SQL_STATEMENT_DELETE

a DELETE statement

 

GDA_SQL_STATEMENT_COMPOUND

a compound statement: multiple SELECT statements grouped together using an operator

 

GDA_SQL_STATEMENT_BEGIN

start of transaction statement

 

GDA_SQL_STATEMENT_ROLLBACK

transaction abort statement

 

GDA_SQL_STATEMENT_COMMIT

transaction commit statement

 

GDA_SQL_STATEMENT_SAVEPOINT

new savepoint definition statement

 

GDA_SQL_STATEMENT_ROLLBACK_SAVEPOINT

return to savepoint statement

 

GDA_SQL_STATEMENT_DELETE_SAVEPOINT

savepoint deletion statement

 

GDA_SQL_STATEMENT_UNKNOWN

unknown statement, only identifies variables

 

GDA_SQL_STATEMENT_NONE

not used

 

enum GdaSqlAnyPartType

Type of part.

Members

GDA_SQL_ANY_STMT_SELECT

structure is a GdaSqlStatementSelect

 

GDA_SQL_ANY_STMT_INSERT

structure is a GdaSqlStatementInsert

 

GDA_SQL_ANY_STMT_UPDATE

structure is a GdaSqlStatementUpdate

 

GDA_SQL_ANY_STMT_DELETE

structure is a GdaSqlStatementDelete

 

GDA_SQL_ANY_STMT_COMPOUND

structure is a GdaSqlStatementCompound

 

GDA_SQL_ANY_STMT_BEGIN

structure is a GdaSqlStatementTransaction

 

GDA_SQL_ANY_STMT_ROLLBACK

structure is a GdaSqlStatementTransaction

 

GDA_SQL_ANY_STMT_COMMIT

structure is a GdaSqlStatementTransaction

 

GDA_SQL_ANY_STMT_SAVEPOINT

structure is a GdaSqlStatementTransaction

 

GDA_SQL_ANY_STMT_ROLLBACK_SAVEPOINT

structure is a GdaSqlStatementTransaction

 

GDA_SQL_ANY_STMT_DELETE_SAVEPOINT

structure is a GdaSqlStatementTransaction

 

GDA_SQL_ANY_STMT_UNKNOWN

structure is a GdaSqlStatementUnknown

 

GDA_SQL_ANY_EXPR

structure is a GdaSqlExpr

 

GDA_SQL_ANY_SQL_FIELD

structure is a GdaSqlField

 

GDA_SQL_ANY_SQL_TABLE

structure is a GdaSqlTable

 

GDA_SQL_ANY_SQL_FUNCTION

structure is a GdaSqlFunction

 

GDA_SQL_ANY_SQL_OPERATION

structure is a GdaSqlOperation

 

GDA_SQL_ANY_SQL_CASE

structure is a GdaSqlCase

 

GDA_SQL_ANY_SQL_SELECT_FIELD

structure is a GdaSqlSelectField

 

GDA_SQL_ANY_SQL_SELECT_TARGET

structure is a GdaSqlSelectTarget

 

GDA_SQL_ANY_SQL_SELECT_JOIN

structure is a GdaSqlSelectJoin

 

GDA_SQL_ANY_SQL_SELECT_FROM

structure is a GdaSqlSelectFrom

 

GDA_SQL_ANY_SQL_SELECT_ORDER

structure is a GdaSqlSelectOrder

 

struct GdaSqlAnyPart

struct GdaSqlAnyPart {
	GdaSqlAnyPartType  type;
	GdaSqlAnyPart     *parent;
};

Base structure of which all structures (except GdaSqlStatement) "inherit". It identifies, for each structure, its type and its parent in the structure hierarchy.

Members

GdaSqlAnyPartType type;

type of structure, as a GdaSqlAnyPartType enum.

 

GdaSqlAnyPart *parent;

pointer to the parent GdaSqlAnyPart structure

 

GdaSqlStatementContentsInfo

typedef struct {
	GdaSqlStatementType  type;
	gchar               *name;
	gpointer            (*construct) (void);
	void                (*free) (gpointer stm);
	gpointer            (*copy) (gpointer stm);
	gchar              *(*serialize) (gpointer stm);

	/* augmenting information precision using a dictionary */
	GdaSqlForeachFunc     check_structure_func;
	GdaSqlForeachFunc     check_validity_func;
} GdaSqlStatementContentsInfo;

Contents' infos


GdaSqlStatementCheckValidityData

typedef struct {
	GdaConnection *cnc;
	GdaMetaStore  *store;
	GdaMetaStruct *mstruct;
} GdaSqlStatementCheckValidityData;

Validation against a dictionary


GdaSqlStatement

typedef struct {
	gchar               *sql;
	GdaSqlStatementType  stmt_type;
	gpointer             contents; /* depends on stmt_type */
	GdaMetaStruct       *validity_meta_struct; /* set when gda_sql_statement_check_validity() was last called */
} GdaSqlStatement;

This structure is the top level structure encapsulating several type of statements.


GdaSqlStatementCompound

typedef struct {
	GdaSqlAnyPart                any;
	GdaSqlStatementCompoundType  compound_type;
	GSList                      *stmt_list; /* list of SELECT or COMPOUND statements */
} GdaSqlStatementCompound;

GdaSqlStatementDelete

typedef struct {
	GdaSqlAnyPart any;
	GdaSqlTable  *table;
	GdaSqlExpr   *cond;
} GdaSqlStatementDelete;

GdaSqlStatementInsert

typedef struct {
	GdaSqlAnyPart           any;
	gchar                  *on_conflict; /* conflict resolution clause */
	GdaSqlTable            *table;
	GSList                 *fields_list; /* list of GdaSqlField structures */
	GSList                 *values_list; /* list of list of GdaSqlExpr */
	GdaSqlAnyPart          *select; /* SELECT OR COMPOUND statements: GdaSqlStatementSelect or GdaSqlStatementCompound */
} GdaSqlStatementInsert;

The statement is an INSERT statement, any kind of INSERT statement can be represented using this structure (if this is not the case then report a bug).

Example of a GdaSqlStatement having a GdaSqlStatementInsert as its contents with 2 lists of values to insert.

Another example of a GdaSqlStatement having a GdaSqlStatementInsert as its contents, using a SELECT to express the values to insert.

Members

GdaSqlAnyPart any;

inheritance structure

 

gchar *on_conflict;

conflict resolution clause if there is one (such as "OR REPLACE")

 

GdaSqlTable *table;

name of the table to which data is inserted

 

GSList *fields_list;

list of GdaSqlField fields which are valued for insertion

 

GSList *values_list;

list of list of GdaSqlExpr expressions (this is a list of list, not a simple list)

 

GdaSqlAnyPart *select;

a GdaSqlStatementSelect or GdaSqlStatementCompound structure representing the values to insert

 

GdaSqlStatementSelect

typedef struct {
	GdaSqlAnyPart     any;
	gboolean          distinct;
	GdaSqlExpr       *distinct_expr;

	GSList           *expr_list;  /* list of GdaSqlSelectField pointers */
	GdaSqlSelectFrom *from;
	
	GdaSqlExpr       *where_cond; /* WHERE... */
	GSList           *group_by; /* list of GdaSqlExpr pointers */
	GdaSqlExpr       *having_cond; /* HAVING... */
	GSList           *order_by;   /* list of GdaSqlSelectOrder pointers */

	GdaSqlExpr       *limit_count;
	GdaSqlExpr       *limit_offset;
} GdaSqlStatementSelect;

GdaSqlStatementTransaction

typedef struct {
	GdaSqlAnyPart           any;
	GdaTransactionIsolation isolation_level;
	gchar                  *trans_mode; /* DEFERRED, IMMEDIATE, EXCLUSIVE, READ_WRITE, READ_ONLY */
	gchar                  *trans_name;
} GdaSqlStatementTransaction;

The statement is a transaction management related statement (BEGIN, ROLLBACK, etc). The GdaSqlStatementTransaction structure does not hold enough information to reconstruct the complete SQL statement (some information may be missing) - the aim of this structure is to identify a minimum set of information in the transaction statement. Note that the complete SQL which created the statement should be available in the GdaSqlStatement structure which encapsulates this structure.

Members

GdaSqlAnyPart any;

inheritance structure

 

GdaTransactionIsolation isolation_level;

isolation level as a GdaTransactionIsolation

 

gchar *trans_mode;

transaction mode (DEFERRED, IMMEDIATE, EXCLUSIVE, READ_WRITE, READ_ONLY)

 

gchar *trans_name;

transaction name

 

GdaSqlStatementUnknown

typedef struct {
	GdaSqlAnyPart  any;
	GSList        *expressions;
} GdaSqlStatementUnknown;

Represents any statement which type is not identified (any DDL statement or database specific dialect)

Members

GdaSqlAnyPart any;

   

GSList *expressions;

a list of GdaSqlExpr pointers

 

GdaSqlStatementUpdate

typedef struct {
	GdaSqlAnyPart     any;
	gchar            *on_conflict; /* conflict resolution clause */
	GdaSqlTable      *table;
	GSList           *fields_list; /* list of GdaSqlField pointers */
	GSList           *expr_list;   /* list of GdaSqlExpr pointers */
	GdaSqlExpr       *cond;
} GdaSqlStatementUpdate;