Some tests use position number in the argument list of psql command
to check their results. As #36787 add one element, next position
in the list must be used.
This update allows granting privileges on ALL tables or ALL sequences
in a given schema. Such as:
GRANT SELECT ON ALL TABLES IN SCHEMA public TO 'monkey';
* Quote postgres privilege target names
Postgres lets you put characters in table/database names which you then must
quote. So we should always quote.
* Updating unit tests
* Also quote role names.
Role names can also have dashes (or others) in them, so we must also quote
them.
* modules.postgres: fix handling of empty string in db_create
The code responsible for collecting the parameters used in the CREATE
DATABASE query works unexpectedly in case for values which are evaluated
to False as bool, but are not None.
This caused queries with missing rvalues like this one (lc_collate=""):
2016-05-13 16:04:05,243 [salt.loaded.int.module.cmdmod][ERROR ][2990]
stderr: ERROR: syntax error at or near "OWNER"
LINE 1: ..._production" WITH ENCODING = 'utf8' LC_COLLATE = OWNER =
"g...
Please note that proper escaping or a different approach would be needed
here.
* modules.postgres: handle trivial sqli in db_create
* modules.postgres: fix OrderedDict usage
* modules.postgres: quote TABLESPACE too in db_create
- In db_create(), use an OrderedDict for options. This probably doesn't
matter in production, but a deterministic order makes the unit test
work across python 2 and 3.
- Use six-abstracted StringIO
- Use 0 instead of None as the expected successful return code
- Pass bytes instead of str to hashlib.md5()
- salt/states/postgres_schema.py: new states for schemas
- tests/unit/modules/postgres_test.py: add tests on new functions
- tests/unit/states/postgres_test.py: add tests on new functions
No matter if we have been given a password or not, it never makes sense
for psql to interactively prompt for a password. It's better to fail
immediately than to hang because psql is waiting for input that will
never happen.
* Fix for inconsistent behavior wherein systems will use varying escaping behavior for quotes and double-quotes. (Most notably, Ubuntu 10 for some oddball reason.
* Reformatting.