Top | ![]() |
![]() |
![]() |
![]() |
GdaConnection * | connection | Read / Write / Construct Only |
int | op-type | Read / Write / Construct Only |
GdaServerProvider * | provider | Read / Write / Construct Only |
char * | spec-filename | Write / Construct Only |
char * | spec-resource | Write / Construct Only |
GBoxed ├── GdaServerOperationCreateTableArg ╰── GdaServerOperationCreateTableArgFKeyRefField GObject ╰── GdaServerOperation
This object is basically just a data store: it can store named values, the values being
organized hierarchically by their name which are similar to a Unix file path. For example a value can be read from its path
using the gda_server_operation_get_value_at()
method, or set using the gda_server_operation_set_value_at()
method.
Each GdaServerOperation contains some structure which is usually defined by a database provider to implement a specific operation. The structure is composed of the following building blocks:
Named values (internally represented as a GdaHolder object)
Named values in a vector (internally represented as a GdaSet object)
Values in an array (internally represented as a GdaDataModel object)
Sequences of one or more of the previous blocks. A sequence can contain any number of instances of the template block (there may be lower and upper boundaries to the number of instances)
Important note: GdaServerOperation objects are usually not created
manually using gda_server_operation_new()
, but
using a GdaServerProvider object with gda_server_provider_create_operation()
.
See the global introduction about DDL for more information.
Alternatively one can use the Convenience functions
which internally manipulate GdaServerOperation objects.
GdaServerOperationType
gda_server_operation_get_op_type (GdaServerOperation *op
);
Get the type of operation op
is for
const gchar *
gda_server_operation_op_type_to_string
(GdaServerOperationType type
);
Get a string version of type
GdaServerOperationType
gda_server_operation_string_to_op_type
(const gchar *str
);
Performs the reverse of gda_server_operation_op_type_to_string()
the GdaServerOperationType represented by str
, or G_MAXINT if str
is not a valid representation
of a GdaServerOperationType
Since: 4.2
const GValue * gda_server_operation_get_value_at (GdaServerOperation *op
,const gchar *path_format
,...
);
Get the value for the node at the path formed using path_format
and ... (the rules are the same as
for g_strdup_printf()
)
op |
a GdaServerOperation object |
|
path_format |
a complete path to a node (starting with "/") |
|
... |
arguments to use with |
const GValue * gda_server_operation_get_value_at_path (GdaServerOperation *op
,const gchar *path
);
Get the value for the node at the path
path
[rename-to gda_server_operation_get_value_at]
a constant GValue if a value has been defined, or NULL
if the value is undefined or if the path
is not defined or path
does not hold any value.
[transfer none][nullable]
Since: 4.2.6
gchar * gda_server_operation_get_sql_identifier_at (GdaServerOperation *op
,const gchar *path_format
,GError **error
,...
);
gchar * gda_server_operation_get_sql_identifier_at_path (GdaServerOperation *op
,const gchar *path
,GError **error
);
gboolean gda_server_operation_set_value_at (GdaServerOperation *op
,const gchar *value
,GError **error
,const gchar *path_format
,...
);
Set the value for the node at the path formed using path_format
and the ... ellipse (the rules are the same as
for g_strdup_printf()
).
Note that trying to set a value for a path which is not used by the current provider, such as "/TABLE_OPTIONS_P/TABLE_ENGINE" for a PostgreSQL connection (this option is only supported for MySQL), will not generate any error; this allows one to give values to a superset of the parameters and thus use the same code for several providers.
Here are the possible formats of path_format
:
If the path corresponds to a GdaHolder, then the parameter is set to "<parameter>value</parameter>"
If the path corresponds to a sequence item like for example "/SEQUENCE_NAME/5/NAME" for the "NAME" value of the 6th item of the "SEQUENCE_NAME" sequence then:
if the sequence already has 6 or more items, then the value is just set to the corresponding value in the 6th item of the sequence
if the sequence has less then 6 items, then items are added up to the 6th one before setting the value to the corresponding in the 6th item of the sequence
If the path corresponds to a GdaDataModel, like for example "/ARRAY/@COLUMN
/5" for the value at the
6th row of the "COLUMN" column of the "ARRAY" data model, then:
if the data model already contains 6 or more rows, then the value is just set
if the data model has less than 6 rows, then rows are added up to the 6th one before setting the value
op |
a GdaServerOperation object |
|
value |
a string. |
[nullable] |
error |
a place to store errors or |
|
path_format |
a complete path to a node (starting with "/") |
|
... |
arguments to use with |
gboolean gda_server_operation_set_value_at_path (GdaServerOperation *op
,const gchar *value
,const gchar *path
,GError **error
);
Set the value for the node at the path formed using path_format
and the ... ellipse (the rules are the same as
for g_strdup_printf()
).
Note that trying to set a value for a path which is not used by the current provider, such as "/TABLE_OPTIONS_P/TABLE_ENGINE" for a PostgreSQL connection (this option is only supported for MySQL), will not generate any error; this allows one to give values to a superset of the parameters and thus use the same code for several providers.
Here are the possible formats of path_format
:
If the path corresponds to a GdaHolder, then the parameter is set to "<parameter>value</parameter>"
If the path corresponds to a sequence item like for example "/SEQUENCE_NAME/5/NAME" for the "NAME" value of the 6th item of the "SEQUENCE_NAME" sequence then:
if the sequence already has 6 or more items, then the value is just set to the corresponding value in the 6th item of the sequence
if the sequence has less then 6 items, then items are added up to the 6th one before setting the value to the corresponding in the 6th item of the sequence
If the path corresponds to a GdaDataModel, like for example "/ARRAY/@COLUMN
/5" for the value at the
6th row of the "COLUMN" column of the "ARRAY" data model, then:
if the data model already contains 6 or more rows, then the value is just set
if the data model has less than 6 rows, then rows are added up to the 6th one before setting the value
[rename-to gda_server_operation_set_value_at]
op |
a GdaServerOperation object |
|
value |
a string. |
[nullable] |
path |
a complete path to a node (starting with "/") |
|
error |
a place to store errors or |
Since: 4.2.6
xmlNodePtr gda_server_operation_save_data_to_xml (GdaServerOperation *op
,GError **error
);
Creates a new xmlNodePtr tree which can be used to save the op object. This XML structure can then be saved to disk if necessary. Use xmlFreeNode to free the associated memory when not needed anymore.
[skip]
gboolean gda_server_operation_load_data_from_xml (GdaServerOperation *op
,xmlNodePtr node
,GError **error
);
Loads the contents of node
into op
. The XML tree passed through the node
argument must correspond to an XML tree saved using gda_server_operation_save_data_to_xml()
.
gboolean gda_server_operation_is_valid (GdaServerOperation *op
,const gchar *xml_file
,GError **error
);
Tells if all the required values in op
have been defined.
if xml_file
is not NULL
, the validity of op
is tested against that specification,
and not against the current op
's specification.
op |
a GdaServerOperation widget |
|
xml_file |
an XML specification file (see |
[nullable] |
error |
a place to store an error, or |
Since: 6.0
gboolean gda_server_operation_is_valid_from_resource (GdaServerOperation *op
,const gchar *resource
,GError **error
);
Tells if all the required values in op
have been defined.
if xml_data
is not NULL
, the validity of op
is tested against that specification,
and not against the current op
's specification.
op |
a GdaServerOperation widget |
|
resource |
the name of a resource containing an XML specification data (see |
[nullable] |
error |
a place to store an error, or |
gchar * gda_server_operation_render (GdaServerOperation *op
,GError **error
);
Creates an SQL statement (possibly using some specific extensions of the DBMS) corresponding to the
op
operation. Note that the returned string may actually contain more than one SQL statement.
This function's purpose is mainly informative to get the actual SQL code which would be executed to perform
the operation; to actually perform the operation, use gda_server_operation_perform()
.
gchar *
gda_server_operation_save_data_to_xml_string
(GdaServerOperation *op
);
GdaServerOperation * gda_server_operation_prepare_create_database (const gchar *provider
,const gchar *db_name
,GError **error
);
Creates a new GdaServerOperation object which contains the specifications required
to create a database. Once these specifications are provided, use
gda_server_operation_perform_create_database()
to perform the database creation.
If db_name
is left NULL
, then the name of the database to create will have to be set in the
returned GdaServerOperation using gda_server_operation_set_value_at()
.
provider |
the database provider to use |
|
db_name |
the name of the database to create, or |
[nullable] |
error |
a place to store errors, or |
new GdaServerOperation object, or NULL
if the provider does not support database
creation.
[transfer full][nullable]
Since: 4.2.3
gboolean gda_server_operation_perform_create_database (GdaServerOperation *op
,const gchar *provider
,GError **error
);
Creates a new database using the specifications in op
. op
can be obtained using
gda_server_provider_create_operation()
, or gda_server_operation_prepare_create_database()
.
provider |
the database provider to use, or |
[nullable] |
op |
a GdaServerOperation object obtained using |
|
error |
a place to store en error, or |
Since: 4.2.3
GdaServerOperation * gda_server_operation_prepare_drop_database (const gchar *provider
,const gchar *db_name
,GError **error
);
Creates a new GdaServerOperation object which contains the specifications required
to drop a database. Once these specifications provided, use
gda_server_operation_perform_drop_database()
to perform the database creation.
If db_name
is left NULL
, then the name of the database to drop will have to be set in the
returned GdaServerOperation using gda_server_operation_set_value_at()
.
provider |
the database provider to use |
|
db_name |
the name of the database to drop, or |
[nullable] |
error |
a place to store errors, or |
new GdaServerOperation object, or NULL
if the provider does not support database
destruction.
[transfer full][nullable]
Since: 4.2.3
gboolean gda_server_operation_perform_drop_database (GdaServerOperation *op
,const gchar *provider
,GError **error
);
Destroys an existing database using the specifications in op
. op
can be obtained using
gda_server_provider_create_operation()
, or gda_server_operation_prepare_drop_database()
.
provider |
the database provider to use, or |
[nullable] |
op |
a GdaServerOperation object obtained using |
|
error |
a place to store en error, or |
Since: 4.2.3
GdaServerOperationCreateTableArgFKeyRefField *
gda_server_operation_create_table_arg_fkey_ref_field_new
(void
);
GdaServerOperationCreateTableArgFKeyRefField *
gda_server_operation_create_table_arg_fkey_ref_field_copy
(GdaServerOperationCreateTableArgFKeyRefField *src
);
void
gda_server_operation_create_table_arg_fkey_ref_field_free
(GdaServerOperationCreateTableArgFKeyRefField *ref
);
gchar *
gda_server_operation_create_table_arg_fkey_ref_field_get_local_field
(GdaServerOperationCreateTableArgFKeyRefField *ref
);
gchar *
gda_server_operation_create_table_arg_fkey_ref_field_get_referenced_field
(GdaServerOperationCreateTableArgFKeyRefField *ref
);
void gda_server_operation_create_table_arg_fkey_ref_field_set_local_field (GdaServerOperationCreateTableArgFKeyRefField *ref
,const gchar *name
);
void gda_server_operation_create_table_arg_fkey_ref_field_set_referenced_field (GdaServerOperationCreateTableArgFKeyRefField *ref
,const gchar *name
);
GdaServerOperationCreateTableArg *
gda_server_operation_create_table_arg_new
(void
);
GdaServerOperationCreateTableArg *
gda_server_operation_create_table_arg_copy
(GdaServerOperationCreateTableArg *src
);
void
gda_server_operation_create_table_arg_free
(GdaServerOperationCreateTableArg *arg
);
gchar *
gda_server_operation_create_table_arg_get_column_name
(GdaServerOperationCreateTableArg *arg
);
GType
gda_server_operation_create_table_arg_get_column_type
(GdaServerOperationCreateTableArg *arg
);
gchar *
gda_server_operation_create_table_arg_get_fkey_ondelete
(GdaServerOperationCreateTableArg *arg
);
gchar *
gda_server_operation_create_table_arg_get_fkey_onupdate
(GdaServerOperationCreateTableArg *arg
);
GType
gda_server_operation_create_table_arg_get_fkey_ref_field_get_type
(void
);
gda_server_operation_create_table_arg_get_fkey_ref_field_get_type
is deprecated and should not be used in newly-written code.
GList *
gda_server_operation_create_table_arg_get_fkey_refs
(GdaServerOperationCreateTableArg *arg
);
a list of references from local to foreign fields type GdaServerOperationCreateTableArgFKeyRefField.
[transfer none][element-type GdaServerOperationCreateTableArgFKeyRefField]
gchar *
gda_server_operation_create_table_arg_get_fkey_table
(GdaServerOperationCreateTableArg *arg
);
GdaServerOperationCreateTableFlag
gda_server_operation_create_table_arg_get_flags
(GdaServerOperationCreateTableArg *arg
);
void gda_server_operation_create_table_arg_set_column_name (GdaServerOperationCreateTableArg *arg
,const gchar *name
);
Sets column name to be created with the new table.
void gda_server_operation_create_table_arg_set_column_type (GdaServerOperationCreateTableArg *arg
,GType ctype
);
void gda_server_operation_create_table_arg_set_fkey_ondelete (GdaServerOperationCreateTableArg *arg
,const gchar *action
);
You should set this if you use a GDA_SERVER_OPERATION_CREATE_TABLE_FKEY_FLAG flag.
void gda_server_operation_create_table_arg_set_fkey_ondupdate (GdaServerOperationCreateTableArg *arg
,const gchar *action
);
void gda_server_operation_create_table_arg_set_fkey_refs (GdaServerOperationCreateTableArg *arg
,GList *refs
);
You should set this if you use a GDA_SERVER_OPERATION_CREATE_TABLE_FKEY_FLAG flag.
void gda_server_operation_create_table_arg_set_fkey_table (GdaServerOperationCreateTableArg *arg
,const gchar *name
);
You should set this if you use a GDA_SERVER_OPERATION_CREATE_TABLE_FKEY_FLAG flag.
void gda_server_operation_create_table_arg_set_flags (GdaServerOperationCreateTableArg *arg
,GdaServerOperationCreateTableFlag flags
);
Sets flags for new column to create with the table.
GdaServerOperationNode *
gda_server_operation_node_copy (GdaServerOperationNode *src
);
void
gda_server_operation_node_free (GdaServerOperationNode *src
);
typedef struct _GdaServerOperationCreateTableArgFKeyRefField GdaServerOperationCreateTableArgFKeyRefField;
“connection”
property“connection” GdaConnection *
Connection to use.
Owner: GdaServerOperation
Flags: Read / Write / Construct Only
“op-type”
property “op-type” int
Type of operation to be done.
Owner: GdaServerOperation
Flags: Read / Write / Construct Only
Allowed values: [0,17]
Default value: 0
“provider”
property“provider” GdaServerProvider *
Database provider which created the object.
Owner: GdaServerOperation
Flags: Read / Write / Construct Only
“spec-filename”
property “spec-filename” char *
XML file which contains the object's data structure.
Owner: GdaServerOperation
Flags: Write / Construct Only
Default value: NULL
“sequence-item-added”
signalvoid user_function (GdaServerOperation *op, char *seq_path, int item_index, gpointer user_data)
Gets emitted whenever a new sequence item (from a sequence template) has been added
[virtual seq_item_added]
op |
||
seq_path |
the path to the new sequence item |
|
item_index |
the index (starting from 0) of the new sequence item in the sequence |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
“sequence-item-remove”
signalvoid user_function (GdaServerOperation *op, char *seq_path, int item_index, gpointer user_data)
Gets emitted whenever a sequence item is about to be removed
[virtual seq_item_remove]
op |
||
seq_path |
the path to the sequence item to be removed |
|
item_index |
the index (starting from 0) of the sequence item in the sequence |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First