You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add connectdbParams and other connection key-value functions
Added a `Storable` instance for an equivalent to `PQconninfoOption` and bindings
for the functions that use the struct:
- PQconnectdbParams
- PQconndefaults
- PQconninfo
- PQconninfoParse
- PQconninfoFree
Also added some wrappers which do a minimum of conversion to `ByteString`s and
make sure memory isn't leaked.
--| Make a connection to the database server in a nonblocking manner.
288
335
connectStart::B.ByteString--^ Connection Info
289
336
->IOConnection
@@ -356,42 +403,65 @@ connectPoll :: Connection
356
403
->IOPollingStatus
357
404
connectPoll = pollHelper c_PQconnectPoll
358
405
359
-
360
-
-- PQconndefaults
361
-
-- Returns the default connection options.
362
-
363
-
-- PQconninfoOption *PQconndefaults(void);
364
-
365
-
-- typedef struct
366
-
-- {
367
-
-- char *keyword; /* The keyword of the option */
368
-
-- char *envvar; /* Fallback environment variable name */
369
-
-- char *compiled; /* Fallback compiled in default value */
370
-
-- char *val; /* Option's current value, or NULL */
371
-
-- char *label; /* Label for field in connect dialog */
372
-
-- char *dispchar; /* Indicates how to display this field
373
-
-- in a connect dialog. Values are:
374
-
-- "" Display entered value as is
375
-
-- "*" Password field - hide value
376
-
-- "D" Debug option - don't show by default */
377
-
-- int dispsize; /* Field size in characters for dialog */
378
-
-- } PQconninfoOption;
379
-
-- Returns a connection options array. This can be used to determine all possible PQconnectdb options and their current default values. The return value points to an array of PQconninfoOption structures, which ends with an entry having a null keyword pointer. The null pointer is returned if memory could not be allocated. Note that the current default values (val fields) will depend on environment variables and other context. Callers must treat the connection options data as read-only.
380
-
381
-
-- After processing the options array, free it by passing it to PQconninfoFree. If this is not done, a small amount of memory is leaked for each call to PQconndefaults.
382
-
383
-
-- PQconninfoParse
384
-
-- Returns parsed connection options from the provided connection string.
-- Parses a connection string and returns the resulting options as an array; or returns NULL if there is a problem with the connection string. This can be used to determine the PQconnectdb options in the provided connection string. The return value points to an array of PQconninfoOption structures, which ends with an entry having a null keyword pointer.
388
-
389
-
-- Note that only options explicitly specified in the string will have values set in the result array; no defaults are inserted.
390
-
391
-
-- If errmsg is not NULL, then *errmsg is set to NULL on success, else to a malloc'd error string explaining the problem. (It is also possible for *errmsg to be set to NULL even when NULL is returned; this indicates an out-of-memory situation.)
392
-
393
-
-- After processing the options array, free it by passing it to PQconninfoFree. If this is not done, some memory is leaked for each call to PQconninfoParse. Conversely, if an error occurs and errmsg is not NULL, be sure to free the error string using PQfreemem.
394
-
406
+
--| Returns a connection options list. This can be used to determine all
407
+
-- possible 'connectdb' options and their current default values. Note that the
408
+
-- current default values ('conninfoValue' fields) will depend on environment
409
+
-- variables and other context.
410
+
conndefaults::IO [ConninfoOption]
411
+
conndefaults =do
412
+
mask_ $ getConnInfos =<< c_PQconndefaults
413
+
414
+
--| Parses a connection string and returns the resulting options as a list.
415
+
-- This can be used to determine the 'connectdb' options in the provided
416
+
-- connection string.
417
+
--
418
+
-- Note that only options explicitly specified in the string will have values
419
+
-- set in the result array; no defaults are inserted.
0 commit comments