198
198
describeFunctions(const char *functypes, const char *pattern, bool verbose, bool showSystem)
200
bool showAggregate = strchr(functypes, 'a') != NULL;
201
bool showNormal = strchr(functypes, 'n') != NULL;
202
bool showTrigger = strchr(functypes, 't') != NULL;
203
bool showWindow = strchr(functypes, 'w') != NULL;
200
bool showAggregate = strchr(functypes, 'a') != NULL;
201
bool showNormal = strchr(functypes, 'n') != NULL;
202
bool showTrigger = strchr(functypes, 't') != NULL;
203
bool showWindow = strchr(functypes, 'w') != NULL;
205
205
PQExpBufferData buf;
207
207
printQueryOpt myopt = pset.popt;
208
static const bool translate_columns[] = {false, false, false, false, true, true, false, false, false, false};
209
210
if (strlen(functypes) != strspn(functypes, "antwS+"))
242
243
" WHEN p.proisagg THEN '%s'\n"
243
244
" WHEN p.proiswindow THEN '%s'\n"
244
" WHEN pg_catalog.pg_get_function_result(p.oid) = 'trigger' THEN '%s'\n"
245
" WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
247
248
gettext_noop("Result data type"),
287
288
" END AS \"%s\",\n"
289
290
" WHEN p.proisagg THEN '%s'\n"
290
" WHEN 'trigger' = pg_catalog.format_type(p.prorettype, NULL) THEN '%s'\n"
291
" WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
292
293
" END AS \"%s\"",
293
294
gettext_noop("Result data type"),
304
305
" pg_catalog.oidvectortypes(p.proargtypes) as \"%s\",\n"
306
307
" WHEN p.proisagg THEN '%s'\n"
307
" WHEN 'trigger' = pg_catalog.format_type(p.prorettype, NULL) THEN '%s'\n"
308
" WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN '%s'\n"
309
310
" END AS \"%s\"",
310
311
gettext_noop("Result data type"),
319
320
appendPQExpBuffer(&buf,
321
" WHEN p.provolatile = 'i' THEN 'immutable'\n"
322
" WHEN p.provolatile = 's' THEN 'stable'\n"
323
" WHEN p.provolatile = 'v' THEN 'volatile'\n"
322
" WHEN p.provolatile = 'i' THEN '%s'\n"
323
" WHEN p.provolatile = 's' THEN '%s'\n"
324
" WHEN p.provolatile = 'v' THEN '%s'\n"
325
326
",\n pg_catalog.pg_get_userbyid(p.proowner) as \"%s\",\n"
326
327
" l.lanname as \"%s\",\n"
327
328
" p.prosrc as \"%s\",\n"
328
329
" pg_catalog.obj_description(p.oid, 'pg_proc') as \"%s\"",
330
gettext_noop("immutable"),
331
gettext_noop("stable"),
332
gettext_noop("volatile"),
329
333
gettext_noop("Volatility"),
330
334
gettext_noop("Owner"),
331
335
gettext_noop("Language"),
340
344
appendPQExpBuffer(&buf,
341
345
" LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang\n");
343
processSQLNamePattern(pset.db, &buf, pattern, false, true,
344
"n.nspname", "p.proname", NULL,
345
"pg_catalog.pg_function_is_visible(p.oid)");
349
/* filter by function type, if requested */
347
350
if (showNormal && showAggregate && showTrigger && showWindow)
348
351
/* Do nothing */;
349
352
else if (showNormal)
351
if (!showWindow && pset.sversion >= 80400)
352
appendPQExpBuffer(&buf, " AND NOT p.proiswindow\n");
353
354
if (!showAggregate)
354
appendPQExpBuffer(&buf, " AND NOT p.proisagg\n");
357
appendPQExpBuffer(&buf, " AND ");
360
appendPQExpBuffer(&buf, "WHERE ");
363
appendPQExpBuffer(&buf, "NOT p.proisagg\n");
355
365
if (!showTrigger)
357
if (pset.sversion >= 80400)
358
appendPQExpBuffer(&buf,
359
" AND pg_catalog.pg_get_function_result(p.oid) <> 'trigger'\n");
361
appendPQExpBuffer(&buf,
362
" AND pg_catalog.format_type(p.prorettype, NULL) <> 'trigger'\n");
368
appendPQExpBuffer(&buf, " AND ");
371
appendPQExpBuffer(&buf, "WHERE ");
374
appendPQExpBuffer(&buf, "p.prorettype <> 'pg_catalog.trigger'::pg_catalog.regtype\n");
376
if (!showWindow && pset.sversion >= 80400)
379
appendPQExpBuffer(&buf, " AND ");
382
appendPQExpBuffer(&buf, "WHERE ");
385
appendPQExpBuffer(&buf, "NOT p.proiswindow\n");
367
390
bool needs_or = false;
369
appendPQExpBuffer(&buf, " AND (\n ");
392
appendPQExpBuffer(&buf, "WHERE (\n ");
394
/* Note: at least one of these must be true ... */
370
395
if (showAggregate)
372
397
appendPQExpBuffer(&buf,"p.proisagg\n");
378
appendPQExpBuffer(&buf, " OR ");
379
if (pset.sversion >= 80400)
380
appendPQExpBuffer(&buf,
381
"pg_catalog.pg_get_function_result(p.oid) = 'trigger'\n");
383
appendPQExpBuffer(&buf,
384
"'trigger' <> pg_catalog.format_type(p.prorettype, NULL)\n");
403
appendPQExpBuffer(&buf, " OR ");
404
appendPQExpBuffer(&buf,
405
"p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype\n");
390
appendPQExpBuffer(&buf, " OR ");
411
appendPQExpBuffer(&buf, " OR ");
391
412
appendPQExpBuffer(&buf, "p.proiswindow\n");
393
415
appendPQExpBuffer(&buf, " )\n");
418
processSQLNamePattern(pset.db, &buf, pattern, have_where, true,
419
"n.nspname", "p.proname", NULL,
420
"pg_catalog.pg_function_is_visible(p.oid)");
396
422
if (!showSystem && !pattern)
397
423
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
398
424
" AND n.nspname <> 'information_schema'\n");
407
433
myopt.nullPrint = NULL;
408
434
myopt.title = _("List of functions");
409
435
myopt.translate_header = true;
436
myopt.translate_columns = translate_columns;
411
438
printQuery(res, &myopt, pset.queryFout, pset.logfile);
1049
1076
"%s, reltablespace\n"
1050
1077
"FROM pg_catalog.pg_class WHERE oid = '%s'",
1052
"pg_catalog.array_to_string(reloptions, E', ')" : ",''"),
1079
"pg_catalog.array_to_string(reloptions, E', ')" : "''"),
1055
1082
else if (pset.sversion >= 80000)