Revision 12796
Added by Aaron Marcuse-Kubitza almost 11 years ago
trunk/lib/sh/db.sh | ||
---|---|---|
377 | 377 |
clog++ pg_schema_exists || die "schema $schema does not exist" |
378 | 378 |
} |
379 | 379 |
|
380 |
pg_table_exists() # usage: [schema=...] table=... pg_table_exists |
|
380 |
pg_table_exists() # usage: prep_try; if [schema=...] table=... pg_table_exists; \ |
|
381 |
# then rethrow; ...; fi; rethrow |
|
382 |
# OR prep_try; table=... pg_table_exists || { rethrow; ...; }; rethrow |
|
381 | 383 |
{ |
382 | 384 |
echo_func; : "${table:?}"; mk_table_esc |
383 |
psql <<<"SELECT NULL FROM $table_esc LIMIT 0" |
|
385 |
prep_try; pattern='relation .* does not exist' \ |
|
386 |
ignore_e=3 stderr_matches psql <<<"SELECT NULL FROM $table_esc LIMIT 0" |
|
384 | 387 |
} |
385 | 388 |
|
386 | 389 |
fi |
Also available in: Unified diff
fix: lib/sh/db.sh: pg_table_exists(): use stderr_matches() rather than just the exit status. this also avoids highlighting the benign error.