gda-statement-struct

gda-statement-struct

Types and Values

Object Hierarchy

    GBoxed
    ╰── GdaSqlStatement

Description

Functions

gda_sql_statement_new ()

GdaSqlStatement *
gda_sql_statement_new (GdaSqlStatementType type);

Use this function to create a GdaSqlStatement of the specified type type.

Parameters

type

type of statement to create

 

Returns

a new GdaSqlStatement


gda_sql_statement_copy ()

GdaSqlStatement *
gda_sql_statement_copy (GdaSqlStatement *stmt);

Creates a copy of stmt .

Parameters

stmt

a GdaSqlStatement pointer

 

Returns

a new GdaSqlStatement


gda_sql_statement_free ()

void
gda_sql_statement_free (GdaSqlStatement *stmt);

Releases any memory associated to stmt .

Parameters

stmt

a GdaSqlStatement pointer

 

gda_sql_statement_serialize ()

gchar *
gda_sql_statement_serialize (GdaSqlStatement *stmt);

Creates a string representation of stmt .

Parameters

stmt

a GdaSqlStatement pointer

 

Returns

a new string


gda_sql_statement_type_to_string ()

const gchar *
gda_sql_statement_type_to_string (GdaSqlStatementType type);

Converts a GdaSqlStatementType to a string, see also gda_sql_statement_string_to_type()

Parameters

type

a GdaSqlStatementType value

 

Returns

a constant string


gda_sql_statement_string_to_type ()

GdaSqlStatementType
gda_sql_statement_string_to_type (const gchar *type);

Converts a string to a GdaSqlStatementType value, see also gda_sql_statement_type_to_string()

Parameters

type

a string representing a GdaSqlStatementType type

 

Returns

a GdaSqlStatementType value


gda_sql_statement_check_structure ()

gboolean
gda_sql_statement_check_structure (GdaSqlStatement *stmt,
                                   GError **error);

Checks for any error in stmt 's structure to make sure the statement is valid (for example a SELECT statement must at least return a column, a DELETE statement must specify which table is targeted).

Parameters

stmt

a GdaSqlStatement pointer

 

error

a place to store errors, or NULL

 

Returns

TRUE if no error occurred


gda_sql_statement_check_validity ()

gboolean
gda_sql_statement_check_validity (GdaSqlStatement *stmt,
                                  GdaConnection *cnc,
                                  GError **error);

If cnc is not NULL, then checks that all the database objects referenced in the statement actually exist in the connection's database (for example the table being updated in a UPDATE statement must exist in the connection's database for the check to succeed). This method fills the stmt ->validity_meta_struct attribute.

If cnc is NULL, then remove any information from a previous call to this method stored in stmt . In this case, the stmt ->validity_meta_struct attribute is cleared.

Also note that some parts of stmt may be modified: for example leading and trailing spaces in aliases or objects names will be removed.

Parameters

stmt

a GdaSqlStatement pointer

 

cnc

a GdaConnection object, or NULL.

[nullable]

error

a place to store errors, or NULL

 

Returns

TRUE if no error occurred


gda_sql_statement_check_validity_m ()

gboolean
gda_sql_statement_check_validity_m (GdaSqlStatement *stmt,
                                    GdaMetaStruct *mstruct,
                                    GError **error);

If mstruct is not NULL, then checks that all the database objects referenced in the statement i actually referenced in mstruct (for example the table being updated in a UPDATE statement must exist in the connection's database for the check to succeed). This method sets the stmt ->validity_meta_struct attribute to mstruct .

If mstruct is NULL, then remove any information from a previous call to this method stored in stmt . In this case, the stmt ->validity_meta_struct attribute is cleared.

Also note that some parts of stmt may be modified: for example leading and trailing spaces in aliases or objects names will be removed.

Parameters

stmt

a GdaSqlStatement pointer

 

mstruct

a GdaMetaStruct object, or NULL.

[nullable]

error

a place to store errors, or NULL

 

Returns

TRUE if no error occurred

Since: 4.2


gda_sql_statement_check_clean ()

void
gda_sql_statement_check_clean (GdaSqlStatement *stmt);

Cleans any data set by a previous call to gda_sql_statement_check_validity().

Parameters

stmt

a pinter to a GdaSqlStatement structure

 

gda_sql_statement_normalize ()

gboolean
gda_sql_statement_normalize (GdaSqlStatement *stmt,
                             GdaConnection *cnc,
                             GError **error);

"Normalizes" (in place) some parts of stmt , which means stmt may be modified. At the moment any "*" field in a SELECT statement will be replaced by one GdaSqlSelectField structure for each field in the referenced table.

Parameters

stmt

a pointer to a GdaSqlStatement structure

 

cnc

a GdaConnection object, or NULL.

[nullable]

error

a place to store errors, or NULL

 

Returns

TRUE if no error occurred


gda_sql_statement_get_contents_infos ()

GdaSqlStatementContentsInfo *
gda_sql_statement_get_contents_infos (GdaSqlStatementType type);

Types and Values

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.

Members

gchar *sql;

   

GdaSqlStatementType stmt_type;

type of statement

 

gpointer contents;

contents, cast it depending on stmt_type (for example to a GdaSqlStatementSelect).

 

GdaMetaStruct *validity_meta_struct;