commit fb39d8d2dc798ddd44611e349dedc0a8d41b35c6 Author: David G. Johnston (DU) Date: Sat Feb 3 00:11:56 2018 +0000 respose to poc diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 5031cd4d70..36e5e482a7 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -15743,10 +15743,10 @@ SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n); - Functions for access to schema variables + Schema Variable Functions - Functions for access to schema variables + Schema Variable Functions functions @@ -15760,10 +15760,12 @@ SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n); These functions allow reading and writing schema variables values. + If the schema variable referenced does not exist (created using ) + these functions will (do something...). - + - Functions for access to chema variables + Functions for access to schema variables @@ -15773,14 +15775,13 @@ SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n); Description - get_schema_variable(variable, expected type) regclass, anyelement anyelement - Returns value of schema variables coverted to expected type. + Returns value of schema variable converted to expected type. @@ -15789,16 +15790,16 @@ SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n); regclass, anyelementvoid - Set a value of schema variable. Value is converted to type of schema variable. + Sets the value of schema variable to value, after converting the input to the correct type.
- + An example: - The usage is very simple: + CREATE TEMP VARIABLE foo AS numeric; SELECT set_schema_variable('foo', 345.445); diff --git a/doc/src/sgml/ref/create_variable.sgml b/doc/src/sgml/ref/create_variable.sgml index 037fa087f5..c06b0e7517 100644 --- a/doc/src/sgml/ref/create_variable.sgml +++ b/doc/src/sgml/ref/create_variable.sgml @@ -16,7 +16,7 @@ PostgreSQL documentation CREATE VARIABLE - define a new schema secure typed variable + define a new permissioned typed schema variable @@ -24,32 +24,39 @@ PostgreSQL documentation CREATE VARIABLE [ IF NOT EXISTS ] name [ AS ] data_type ] + Description CREATE VARIABLE creates a new schema variable. - These variables are memory only non transactional, but typed and - secure. The access is controlled by rights defined by command - GRANT and command REVOKE. + These variables are scalar typed, non-transactional, and, like relations, + exist within a schema with access controlled via + GRANT and REVOKE. - The schema variable is initialized to NULL value. The content of - variable is lost when session is destroyed. + The value of a schema variable is session-local. Retrieving + a variable's value will return NULL unless its value has been set + to something else in the current session. - The schema variable can be any scalar only. - type. + Retrieval is done via the get_schema_variabledunxrion or the SQL + command SELECT. Setting of values is done via the + set_schema_variable function or the SQL command + LET. + Notably, while schema variables are in many ways a kind of table you cannot use + UPDATE on them. - After a variable is created, you use the special functions - get_schema_variables, set_schema_variables. - type. - + For purposes of name uniqueness relation-like objects (e.g., tables, indexes) + within the same schema are considered. i.e., you cannot give a table and a + schema variable the same name. This is a consequence of them being treated + like relations for purposes of SELECT. @@ -60,10 +67,9 @@ CREATE VARIABLE [ IF NOT EXISTS ] nameIF NOT EXISTS - Do not throw an error if a relation with the same name already exists. - A notice is issued in this case. Note that there is no guarantee that - the existing relation is anything like the variable that would have - been created - it might not even be a variable. + Do not throw an error if the name already exists. A notice is issued in this case. + Note that type of the variable is not considered, nor could it be since the namespace + searched contains non-variable objects. @@ -81,7 +87,7 @@ CREATE VARIABLE [ IF NOT EXISTS ] namedata_type - The name (optionally schema-qualified) of the data type ofvariable to be created. + The name (optionally schema-qualified) of the data type of the variable to be created. @@ -107,7 +113,7 @@ CREATE VARIABLE var1 AS integer; - Set a value of this variable: + Set this variable's value; then retrieve it converted to numeric. CREATE VARIABLE postgres=# select set_schema_variable('var1', 10); @@ -129,7 +135,8 @@ postgres=# select get_schema_variable('var1', null::numeric); Compatibility - CREATE VARIABLE is PostgreSQL feature + CREATE VARIABLE is a PostgreSQL feature. + diff --git a/doc/src/sgml/ref/discard.sgml b/doc/src/sgml/ref/discard.sgml index b348c02e0b..395453bba0 100644 --- a/doc/src/sgml/ref/discard.sgml +++ b/doc/src/sgml/ref/discard.sgml @@ -79,7 +79,8 @@ DISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP | VARIABLES} VARIABLES - Releases content of all schema variables in current session. + Sets the value of all schema variables to NULL. + diff --git a/doc/src/sgml/ref/drop_variable.sgml b/doc/src/sgml/ref/drop_variable.sgml index f6c2e46476..06130fd510 100644 --- a/doc/src/sgml/ref/drop_variable.sgml +++ b/doc/src/sgml/ref/drop_variable.sgml @@ -29,8 +29,9 @@ DROP VARIABLE [ IF EXISTS ] name [, Description - DROP VARIABLE removes schema variable. + DROP VARIABLE removes a schema variable. A variable can only be dropped by its owner or a superuser. + @@ -75,6 +76,8 @@ DROP VARIABLE var1; DROP VARIABLE is proprietary PostgreSQL command. + diff --git a/doc/src/sgml/ref/grant.sgml b/doc/src/sgml/ref/grant.sgml index 7dde54ce0f..006364ebe5 100644 --- a/doc/src/sgml/ref/grant.sgml +++ b/doc/src/sgml/ref/grant.sgml @@ -173,6 +173,7 @@ GRANT role_name [, ...] TO PUBLIC are as follows: @@ -210,6 +211,8 @@ GRANT role_name [, ...] TO currval function. For large objects, this privilege allows the object to be read. + For schema variables, this privilege allows the get_schema_variable + to read the variable's value. @@ -245,6 +248,9 @@ GRANT role_name [, ...] TO setval functions. For large objects, this privilege allows writing or truncating the object. + For schema variables, this privilege allows LET + and set_schema_variable to modify the schema variable's + value. diff --git a/doc/src/sgml/ref/let.sgml b/doc/src/sgml/ref/let.sgml index b040b5e1fe..e8bf3f6dd4 100644 --- a/doc/src/sgml/ref/let.sgml +++ b/doc/src/sgml/ref/let.sgml @@ -16,7 +16,7 @@ PostgreSQL documentation LET - change a schema variable + change a schema variable's value @@ -29,7 +29,7 @@ LET schema_variable = Description - The LET command sets specified schema variable. + The LET command updates the specified schema variable' value. @@ -42,7 +42,7 @@ LET schema_variable = schema_variable - Specifies that the name of schema variable. + The name of schema variable. @@ -51,7 +51,7 @@ LET schema_variable = sql expression - Any SQL expression. + An SQL expression, the result is cast to the schema variable's type. @@ -71,6 +71,8 @@ LET myvar = (SELECT sum(val) FROM tab); Compatibility + LET extends syntax defined in the SQL standard. The standard knows SET command, that is used for different purpouse in PostgreSQL.