* PQconndefaults * * Construct a default connection options array, which identifies all the * available options and shows any default values that are available from the * environment etc. On error (eg out of memory), NULL is returned. * * Using this function, an application may determine all possible options * and their current default values. * * NOTE: as of PostgreSQL 7.0, the returne
| 1543 | * until they are updated to call PQconninfoFree. |
| 1544 | */ |
| 1545 | PQconninfoOption * |
| 1546 | PQconndefaults(void) |
| 1547 | { |
| 1548 | PQExpBufferData errorBuf; |
| 1549 | PQconninfoOption *connOptions; |
| 1550 | |
| 1551 | /* We don't actually report any errors here, but callees want a buffer */ |
| 1552 | initPQExpBuffer(&errorBuf); |
| 1553 | if (PQExpBufferDataBroken(errorBuf)) |
| 1554 | return NULL; /* out of memory already :-( */ |
| 1555 | |
| 1556 | connOptions = conninfo_init(&errorBuf); |
| 1557 | if (connOptions != NULL) |
| 1558 | { |
| 1559 | /* pass NULL errorBuf to ignore errors */ |
| 1560 | if (!conninfo_add_defaults(connOptions, NULL)) |
| 1561 | { |
| 1562 | PQconninfoFree(connOptions); |
| 1563 | connOptions = NULL; |
| 1564 | } |
| 1565 | } |
| 1566 | |
| 1567 | termPQExpBuffer(&errorBuf); |
| 1568 | return connOptions; |
| 1569 | } |
| 1570 | |
| 1571 | /* ---------------- |
| 1572 | * PQsetdbLogin |