[Vala] Strange Behaviour?
- From: Peter Cartwright <peter public use gmail com>
- To: vala-list gnome org
- Subject: [Vala] Strange Behaviour?
- Date: Wed, 27 Jun 2012 15:12:45 +0800
Hello Vala-ites!
I'm working with the Mysql package and I'm stuck with something.
row1 = results.fetch_row ();
row2 = results.fetch_row ();
row1 and row2 are unique. No problem.
But..
fields1 = field_results.fetch_fields ();
fields2 = field_results.fetch_fields ();
fields1 seems to interfere with fields2. Are they pointing to the same
memory space?
Is this expected behaviour?
In the code example below (with output) you can see that a reference kept
to the first fetch_fields() (temp) get overwritten (garbled?) by subsequent
fetch_fields().
Code Example:
--------------------------------
var row = results.fetch_row ();
var table = row[0];
var field_results = _DB.db.list_fields (table);
var fields = field_results.fetch_fields ();
var temp = fields;
stdout.printf("1)\n");
stdout.printf(" %s\n", table);
stdout.printf(" %s\n", fields[0].name);
stdout.printf("temp: %s\n", temp[0].name);
row = results.fetch_row ();
table = row[0];
field_results = _DB.db.list_fields (table);
fields = field_results.fetch_fields ();
stdout.printf("2)\n");
stdout.printf(" %s\n", table);
stdout.printf(" %s\n", fields[0].name);
stdout.printf("temp: %s\n", temp[0].name);
row = results.fetch_row ();
table = row[0];
field_results = _DB.db.list_fields (table);
fields = field_results.fetch_fields ();
stdout.printf("3)\n");
stdout.printf(" %s\n", table);
stdout.printf(" %s\n", fields[0].name);
stdout.printf("temp: %s\n", temp[0].name);
row = results.fetch_row ();
table = row[0];
field_results = _DB.db.list_fields (table);
fields = field_results.fetch_fields ();
stdout.printf("4)\n");
stdout.printf(" %s\n", table);
stdout.printf(" %s\n", fields[0].name);
stdout.printf("temp: %s\n", temp[0].name);
row = results.fetch_row ();
table = row[0];
field_results = _DB.db.list_fields (table);
fields = field_results.fetch_fields ();
stdout.printf("5)\n");
stdout.printf(" %s\n", table);
stdout.printf(" %s\n", fields[0].name);
stdout.printf("temp: %s\n", temp[0].name);
Output:
---------------------------
1)
AreaAccessAuthorisation
idAreaAccess
temp: idAreaAccess
2)
AreaClosedTimes
idAreaClosedTimes
temp: idAreaAccess
3)
AreaOpenAndClosedTimes
idAreaOpenTimes
temp: idAreaOpenTimes
4)
AreaOpenTimes
idAreaOpenTimes
temp: idAreaOpenTimes
5)
Areas
idAreas
temp:
cheers,
Peter
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]