[libgda/LIBGDA_4.2] Misc provider corrections related to iterators
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda/LIBGDA_4.2] Misc provider corrections related to iterators
- Date: Wed, 21 Sep 2011 16:06:35 +0000 (UTC)
commit e741444594f444a8a0096b828a70bc3868ae8877
Author: Vivien Malerba <malerba gnome-db org>
Date: Sun Sep 18 19:04:08 2011 +0200
Misc provider corrections related to iterators
providers/firebird/gda-firebird-recordset.c | 8 +++---
providers/jdbc/gda-jdbc-recordset.c | 18 +++++++++++-
providers/oracle/gda-oracle-recordset.c | 13 +++++++++
.../skel-implementation/capi/gda-capi-recordset.c | 29 +++++++++-----------
providers/web/gda-web-recordset.c | 2 +-
5 files changed, 47 insertions(+), 23 deletions(-)
---
diff --git a/providers/firebird/gda-firebird-recordset.c b/providers/firebird/gda-firebird-recordset.c
index 050bfb1..332df76 100644
--- a/providers/firebird/gda-firebird-recordset.c
+++ b/providers/firebird/gda-firebird-recordset.c
@@ -240,7 +240,7 @@ gda_firebird_recordset_fetch_nb_rows (GdaDataSelect *model)
*
* NOTES:
* - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
* - memory management for that new GdaRow object is left to the implementation, which
* can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
* this method won't be called anymore for the same @rownum), or may decide to
@@ -285,7 +285,7 @@ gda_firebird_recordset_store_all (GdaDataSelect *model, GError **error)
*
* NOTES:
* - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
* - memory management for that new GdaRow object is left to the implementation, which
* can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
* this method won't be called anymore for the same @rownum), or may decide to
@@ -308,7 +308,7 @@ gda_firebird_recordset_fetch_next (GdaDataSelect *model, GdaRow **prow, gint row
*
* NOTES:
* - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
* - memory management for that new GdaRow object is left to the implementation, which
* can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
* this method won't be called anymore for the same @rownum), or may decide to
@@ -332,7 +332,7 @@ gda_firebird_recordset_fetch_prev (GdaDataSelect *model, GdaRow **prow, gint row
*
* NOTES:
* - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
* - memory management for that new GdaRow object is left to the implementation, which
* can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
* this method won't be called anymore for the same @rownum), or may decide to
diff --git a/providers/jdbc/gda-jdbc-recordset.c b/providers/jdbc/gda-jdbc-recordset.c
index de070ce..e084290 100644
--- a/providers/jdbc/gda-jdbc-recordset.c
+++ b/providers/jdbc/gda-jdbc-recordset.c
@@ -505,7 +505,7 @@ gda_jdbc_recordset_fetch_random (GdaDataSelect *model, GdaRow **prow, gint rownu
* if set, is discarded.
*/
static gboolean
-gda_jdbc_recordset_fetch_next (GdaDataSelect *model, GdaRow **prow, G_GNUC_UNUSED gint rownum, GError **error)
+gda_jdbc_recordset_fetch_next (GdaDataSelect *model, GdaRow **prow, gint rownum, GError **error)
{
GdaJdbcRecordset *imodel = (GdaJdbcRecordset*) model;
JNIEnv *jenv = NULL;
@@ -515,9 +515,23 @@ gda_jdbc_recordset_fetch_next (GdaDataSelect *model, GdaRow **prow, G_GNUC_UNUSE
if (!jenv)
return FALSE;
- if (imodel->priv->tmp_row)
+ if (imodel->priv->tmp_row) {
g_object_unref (imodel->priv->tmp_row);
+ imodel->priv->tmp_row = NULL;
+ }
+ if (imodel->priv->next_row_num != rownum) {
+ GError *lerror = NULL;
+ *prow = NULL;
+ g_set_error (&lerror, GDA_DATA_MODEL_ERROR,
+ GDA_DATA_MODEL_ROW_NOT_FOUND_ERROR,
+ "%s", _("Can't set iterator on requested row"));
+ gda_data_select_add_exception (GDA_DATA_SELECT (model), lerror);
+ if (error)
+ g_propagate_error (error, g_error_copy (lerror));
+ _gda_jdbc_release_jenv (jni_detach);
+ return TRUE;
+ }
*prow = fetch_next_jdbc_row (imodel, jenv, FALSE, error);
imodel->priv->tmp_row = *prow;
diff --git a/providers/oracle/gda-oracle-recordset.c b/providers/oracle/gda-oracle-recordset.c
index 6cc63ac..71f2e01 100644
--- a/providers/oracle/gda-oracle-recordset.c
+++ b/providers/oracle/gda-oracle-recordset.c
@@ -619,6 +619,19 @@ gda_oracle_recordset_fetch_random (GdaDataSelect *model, GdaRow **prow, gint row
static gboolean
gda_oracle_recordset_fetch_next (GdaDataSelect *model, GdaRow **prow, gint rownum, GError **error)
{
+ GdaOracleRecordset *imodel = (GdaOracleRecordset*) model;
+
+ if (imodel->priv->next_row_num != rownum) {
+ GError *lerror = NULL;
+ *prow = NULL;
+ g_set_error (&lerror, GDA_DATA_MODEL_ERROR,
+ GDA_DATA_MODEL_ROW_NOT_FOUND_ERROR,
+ "%s", _("Can't set iterator on requested row"));
+ gda_data_select_add_exception (GDA_DATA_SELECT (model), lerror);
+ if (error)
+ g_propagate_error (error, g_error_copy (lerror));
+ return TRUE;
+ }
*prow = fetch_next_oracle_row ((GdaOracleRecordset*) model, TRUE, error);
return TRUE;
}
diff --git a/providers/skel-implementation/capi/gda-capi-recordset.c b/providers/skel-implementation/capi/gda-capi-recordset.c
index 3868299..7c726c9 100644
--- a/providers/skel-implementation/capi/gda-capi-recordset.c
+++ b/providers/skel-implementation/capi/gda-capi-recordset.c
@@ -246,7 +246,7 @@ gda_capi_recordset_fetch_nb_rows (GdaDataSelect *model)
*
* NOTES:
* - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
* - memory management for that new GdaRow object is left to the implementation, which
* can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
* this method won't be called anymore for the same @rownum), or may decide to
@@ -255,14 +255,11 @@ gda_capi_recordset_fetch_nb_rows (GdaDataSelect *model)
* - this method is only called when data model is used in random access mode
*/
static gboolean
-gda_capi_recordset_fetch_random (GdaDataSelect *model, G_GNUC_UNUSED GdaRow **prow, G_GNUC_UNUSED gint rownum,
- G_GNUC_UNUSED GError **error)
+gda_capi_recordset_fetch_random (GdaDataSelect *model, GdaRow **prow, gint rownum,
+ GError **error)
{
- GdaCapiRecordset *imodel;
-
- imodel = GDA_CAPI_RECORDSET (model);
+ /*GdaCapiRecordset *imodel = GDA_CAPI_RECORDSET (model);*/
- g_warning("imodel not used: %p", imodel); /* Avoids a compiler warning. */
TO_IMPLEMENT;
return TRUE;
@@ -295,7 +292,7 @@ gda_capi_recordset_store_all (GdaDataSelect *model, GError **error)
*
* NOTES:
* - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
* - memory management for that new GdaRow object is left to the implementation, which
* can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
* this method won't be called anymore for the same @rownum), or may decide to
@@ -304,8 +301,8 @@ gda_capi_recordset_store_all (GdaDataSelect *model, GError **error)
* - this method is only called when data model is used in cursor access mode
*/
static gboolean
-gda_capi_recordset_fetch_next (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED GdaRow **prow,
- G_GNUC_UNUSED gint rownum, G_GNUC_UNUSED GError **error)
+gda_capi_recordset_fetch_next (GdaDataSelect *model, GdaRow **prow,
+ gint rownum, GError **error)
{
/* GdaCapiRecordset *imodel = (GdaCapiRecordset*) model; */
@@ -319,7 +316,7 @@ gda_capi_recordset_fetch_next (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED
*
* NOTES:
* - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
* - memory management for that new GdaRow object is left to the implementation, which
* can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
* this method won't be called anymore for the same @rownum), or may decide to
@@ -329,8 +326,8 @@ gda_capi_recordset_fetch_next (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED
* - this method is only called when data model is used in cursor access mode
*/
static gboolean
-gda_capi_recordset_fetch_prev (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED GdaRow **prow,
- G_GNUC_UNUSED gint rownum, G_GNUC_UNUSED GError **error)
+gda_capi_recordset_fetch_prev (GdaDataSelect *model, GdaRow **prow,
+ gint rownum, GError **error)
{
/* GdaCapiRecordset *imodel = (GdaCapiRecordset*) model; */
@@ -344,7 +341,7 @@ gda_capi_recordset_fetch_prev (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED
*
* NOTES:
* - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
* - memory management for that new GdaRow object is left to the implementation, which
* can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
* this method won't be called anymore for the same @rownum), or may decide to
@@ -354,8 +351,8 @@ gda_capi_recordset_fetch_prev (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED
* - this method is only called when data model is used in cursor access mode
*/
static gboolean
-gda_capi_recordset_fetch_at (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED GdaRow **prow,
- G_GNUC_UNUSED gint rownum, G_GNUC_UNUSED GError **error)
+gda_capi_recordset_fetch_at (GdaDataSelect *model, GdaRow **prow,
+ gint rownum, GError **error)
{
/* GdaCapiRecordset *imodel = (GdaCapiRecordset*) model; */
diff --git a/providers/web/gda-web-recordset.c b/providers/web/gda-web-recordset.c
index d2cd6cc..ca92682 100644
--- a/providers/web/gda-web-recordset.c
+++ b/providers/web/gda-web-recordset.c
@@ -333,7 +333,7 @@ gda_web_recordset_fetch_nb_rows (GdaDataSelect *model)
* Create a new filled #GdaRow object for the row at position @rownum, and put it into *prow.
*
* WARNING: @prow will NOT be NULL, but *prow may or may not be NULL:
- * - If *prow is NULL then a new #GdaRow object has to be created,
+ * - If *prow is NULL then a new #GdaRow object has to be created, corresponding to the @rownum row
* - and otherwise *prow contains a #GdaRow object which has already been created
* (through a call to this very function), and in this case it should not be modified
* but the function may return FALSE if an error occurred.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]