The following peace of code returns sometimes a result with only 1
field, whereas i'm waiting for a result with 3 fields.
How can such a SELECT return less than the field count required ?

Here are the query, *result and mysql just after the mysql_fetch_row()

Thanks if you can help me

Christophe

(gdb) x/3s buf
0xbfffabc8:      "SELECT ag_id,call_ref,rfgi FROM voies_ag,voies WHERE
dac_id=0 AND voies_ag.voie=voies.voie \t\t\t\tAND voies_ag.etat=1 AND
DATE_ADD(voies_ag.date_etat,INTERVAL 40 SECOND)<NOW() \t\t\t\tAND
DATE_ADD(voies.date"...
0xbfffac90:      ",INTERVAL 40 SECOND)<NOW() \t\t\t\tAND
voies.trafic='", '0' <repeats 151 times>...
0xbfffad58:      '0' <repeats 104 times>, "' AND voies_ag.renvoi=0"
(gdb) print *result
$2 = {row_count = 1, field_count = 1, current_field = 0, fields =
0x80c0438,
  data = 0x80be490, data_cursor = 0x0, field_alloc = {free = 0x80c0428,
    used = 0x0, min_malloc = 16, block_size = 8164, error_handler = 0},
  row = 0x0, current_row = 0x80c2428, lengths = 0x80be484, handle = 0x0,

  eof = 1 '\001'}
(gdb) print mysql
$3 = {net = {nettype = NET_TYPE_TCPIP, fd = 6, fcntl = 0,
    buff = 0x80bbf50 "þ", buff_end = 0x80bdf50 "", write_pos = 0x80bbf50
"þ",
    read_pos = 0x80bbf50 "þ", last_error = '\000' <repeats 199 times>,
    last_errno = 0, max_packet = 8192, timeout = 30, pkt_nr = 6,
    error = 0 '\000', return_errno = 0 '\000', compress = 0 '\000',
    remain_in_buf = 0, length = 0, buf_length = 0, where_b = 0,
    more = 0 '\000', save_char = 0 '\000'}, host = 0x80bbe48 "dcs1",
  user = 0x80bbe50 "root", passwd = 0x80bbe58 "", unix_socket = 0x0,
  server_version = 0x80bbe68 "3.22.32-log",
  host_info = 0x80bbe38 "dcs1 via TCP/IP", info = 0x0,
  db = 0x80bbe88 "acropol", port = 3306, client_flag = 0,
  server_capabilities = 12, protocol_version = 10, field_count = 1,
  thread_id = 5360, affected_rows = 1, insert_id = 0, extra_info = 0,
  packet_length = 1, status = MYSQL_STATUS_READY, fields = 0x0,
field_alloc = {
    free = 0x80c0428, used = 0x0, min_malloc = 16, block_size = 8164,
    error_handler = 0}, free_me = 0 '\000', reconnect = 1 '\001',
options = {
    connect_timeout = 0, client_flag = 0, compress = 0 '\000',
    named_pipe = 0 '\000', port = 0, host = 0x0, init_command = 0x0,
    user = 0x0, password = 0x0, unix_socket = 0x0, db = 0x0,
    my_cnf_file = 0x0, my_cnf_group = 0x0}}


  char buf[1024];
  MYSQL_RES *result;
  MYSQL_ROW row;
  char zero[256];

  memset(zero,'0',255);
  zero[255]=0;
  snprintf(buf,sizeof(buf),"SELECT ag_id,call_ref,rfgi FROM
voies_ag,voies WHERE dac_id=%d AND voies_ag.voie=voies.voie \
    AND voies_ag.etat=%d AND DATE_ADD(voies_ag.date_etat,INTERVAL %d
SECOND)<NOW() \
    AND DATE_ADD(voies.date,INTERVAL %d SECOND)<NOW() \
    AND voies.trafic='%s' AND voies_ag.renvoi=0",
   dac.id,ETAT_AG_CONF,INACTIF_TIMEOUT*2,INACTIF_TIMEOUT*2,zero);
  if (mysql_query(&mysql,buf)) MYSQLABORT("mysql_query");
  if (!(result = mysql_store_result(&mysql)))
MYSQLABORT("mysql_store_result");
  while ((row=mysql_fetch_row(result))) {
   maj_etat(atoi(row[2]),ETAT_AG_FIN_CONF);
   dcs_default_call_withdrawal(dac.sk,atoi(row[0]),atoi(row[1]));
  }
  mysql_free_result(result);



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to