|
Line
Link Here
|
| 0 |
-- src/dm_db.c |
0 |
++ src/dm_db.c |
|
Lines 568-584
Link Here
|
| 568 |
|
575 |
|
| 569 |
if (! db_result_next(r)) { /* ignore */ } |
576 |
if (! db_result_next(r)) { /* ignore */ } |
| 570 |
|
577 |
|
| 571 |
// lastRowId is always zero for pgsql tables without OIDs |
578 |
// The old methods of handling results no longer work. |
| 572 |
// or possibly for sqlite after calling executeQuery but |
579 |
// Use the database driver to determine how to retrieve the resulting |
| 573 |
// before calling db_result_next |
580 |
// message id. |
| 574 |
|
581 |
switch (db_params.db_driver) |
| 575 |
if ((id = (uint64_t )Connection_lastRowId(c)) == 0) { // mysql |
582 |
{ |
| 576 |
// but if we're using 'RETURNING id' clauses on inserts |
583 |
case DM_DRIVER_POSTGRESQL: |
| 577 |
// or we're using the sqlite backend, we can do this |
584 |
id = db_result_get_u64(r, 0); // postgresql |
|
|
585 |
break; |
| 586 |
|
| 587 |
case DM_DRIVER_SQLITE: |
| 588 |
case DM_DRIVER_MYSQL: |
| 589 |
case DM_DRIVER_ORACLE: |
| 590 |
id = (uint64_t) Connection_lastRowId(c); // sqlite, mysql, oracle |
| 591 |
break; |
| 578 |
|
592 |
|
| 579 |
if ((id = (uint64_t )Connection_lastRowId(c)) == 0) // sqlite |
593 |
default: |
| 580 |
id = db_result_get_u64(r, 0); // postgresql |
594 |
TRACE(TRACE_DATABASE, "Unknown driver"); |
|
|
595 |
break; |
| 581 |
} |
596 |
} |
|
|
597 |
|
| 582 |
assert(id); |
598 |
assert(id); |
| 583 |
return id; |
599 |
return id; |
| 584 |
} |
600 |
} |