[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread sansanichfb
Github user sansanichfb commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105483266
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,283 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+The PL/pgSQL language addresses some of these limitations. When creating 
functions with PL/pgSQL, you can group computation blocks and queries inside 
the database server, combining the power of a procedural language and the ease 
of use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   Re-using prepared queries avoids multiple rounds of query parsing
+ 
 
-With PL/pgSQL, you can group a block of computation and a series of 
queries inside the database server, thus having the power of a procedural 
language and the ease of use of SQL, but with considerable savings of 
client/server communication overhead.
+## PL/pgSQL Function Syntax
 
--   Extra round trips between client and server are eliminated
--   Intermediate results that the client does not need do not have to be 
marshaled or transferred between server and client
--   Multiple rounds of query parsing can be avoided
+PL/pgSQL is a block-structured language. The complete text of a function 
definition must be a block, which is defined as:
 
-This can result in a considerable performance increase as compared to an 
application that does not use stored functions.
+``` sql
+[  ]
+[ DECLARE
+declarations ]
+BEGIN
+statements
+END [ label ];
+```
--- End diff --

got it


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread lisakowen
Github user lisakowen commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105483070
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,283 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+The PL/pgSQL language addresses some of these limitations. When creating 
functions with PL/pgSQL, you can group computation blocks and queries inside 
the database server, combining the power of a procedural language and the ease 
of use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   Re-using prepared queries avoids multiple rounds of query parsing
+ 
 
-With PL/pgSQL, you can group a block of computation and a series of 
queries inside the database server, thus having the power of a procedural 
language and the ease of use of SQL, but with considerable savings of 
client/server communication overhead.
+## PL/pgSQL Function Syntax
 
--   Extra round trips between client and server are eliminated
--   Intermediate results that the client does not need do not have to be 
marshaled or transferred between server and client
--   Multiple rounds of query parsing can be avoided
+PL/pgSQL is a block-structured language. The complete text of a function 
definition must be a block, which is defined as:
 
-This can result in a considerable performance increase as compared to an 
application that does not use stored functions.
+``` sql
+[  ]
+[ DECLARE
+declarations ]
+BEGIN
+statements
+END [ label ];
+```
--- End diff --

thanks for reviewing, @sansanichfb!  i used the block definition identified 
in the postgres pl/pgsql docs.  i will add a blurb about exceptions and error 
handling.  (i didn't want to duplicate all of the postgres info on this page, 
my goal was to provide some introductory info and examples to get the user up 
and running with using pl/pgsql in common use scenarios.)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread sansanichfb
Github user sansanichfb commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105477434
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,283 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+The PL/pgSQL language addresses some of these limitations. When creating 
functions with PL/pgSQL, you can group computation blocks and queries inside 
the database server, combining the power of a procedural language and the ease 
of use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   Re-using prepared queries avoids multiple rounds of query parsing
+ 
 
-With PL/pgSQL, you can group a block of computation and a series of 
queries inside the database server, thus having the power of a procedural 
language and the ease of use of SQL, but with considerable savings of 
client/server communication overhead.
+## PL/pgSQL Function Syntax
 
--   Extra round trips between client and server are eliminated
--   Intermediate results that the client does not need do not have to be 
marshaled or transferred between server and client
--   Multiple rounds of query parsing can be avoided
+PL/pgSQL is a block-structured language. The complete text of a function 
definition must be a block, which is defined as:
 
-This can result in a considerable performance increase as compared to an 
application that does not use stored functions.
+``` sql
+[  ]
+[ DECLARE
+declarations ]
+BEGIN
+statements
+END [ label ];
+```
--- End diff --

Maybe add EXCEPTION block as well.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread lisakowen
Github user lisakowen commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105472939
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,278 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+PL/pgSQL does not have these limitations. When creating functions with the 
PL/pgSQL language, you can group computation blocks and queries inside the 
database server, combining the power of a procedural language and the ease of 
use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   You avoid multiple rounds of query parsing
+ 
 
-With PL/pgSQL, you can group a block of computation and a series of 
queries inside the database server, thus having the power of a procedural 
language and the ease of use of SQL, but with considerable savings of 
client/server communication overhead.
+## PL/pgSQL Function Syntax
 
--   Extra round trips between client and server are eliminated
--   Intermediate results that the client does not need do not have to be 
marshaled or transferred between server and client
--   Multiple rounds of query parsing can be avoided
+PL/pgSQL is a block-structured language. The complete text of a function 
definition must be a block, which is defined as:
 
-This can result in a considerable performance increase as compared to an 
application that does not use stored functions.
+``` sql
+[  ]
+[ DECLARE
+declarations ]
+BEGIN
+statements
+END [ label ];
+```
 
-PL/pgSQL supports all the data types, operators, and functions of SQL.
+Each declaration and each statement within a block is terminated by a 
semicolon. A block that appears within another block must have a semicolon 
after `END`, as shown above; however the final `END` that concludes a function 
body does not require a semicolon.
+
+You can specify all key words and identifiers in mixed upper and lower 
case. Identifiers are implicitly converted to lowercase unless double-quoted.
+
+PL/pgSQL supports two types of comments. A double dash (`--`) starts a 
comment that extends to the end of the line. A `/*` starts a block comment that 
extends to the next occurrence of `*/`. Block comments cannot be nested, but 
you can enclose double dash comments into a block comment and a double dash can 
hide the block comment delimiters `/*` and `*/`.
+
+This example PL/pgSQL function adds thirteen to an 

[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread dyozie
Github user dyozie commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105446543
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,278 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+PL/pgSQL does not have these limitations. When creating functions with the 
PL/pgSQL language, you can group computation blocks and queries inside the 
database server, combining the power of a procedural language and the ease of 
use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   You avoid multiple rounds of query parsing
+ 
 
-With PL/pgSQL, you can group a block of computation and a series of 
queries inside the database server, thus having the power of a procedural 
language and the ease of use of SQL, but with considerable savings of 
client/server communication overhead.
+## PL/pgSQL Function Syntax
 
--   Extra round trips between client and server are eliminated
--   Intermediate results that the client does not need do not have to be 
marshaled or transferred between server and client
--   Multiple rounds of query parsing can be avoided
+PL/pgSQL is a block-structured language. The complete text of a function 
definition must be a block, which is defined as:
 
-This can result in a considerable performance increase as compared to an 
application that does not use stored functions.
+``` sql
+[  ]
+[ DECLARE
+declarations ]
+BEGIN
+statements
+END [ label ];
+```
 
-PL/pgSQL supports all the data types, operators, and functions of SQL.
+Each declaration and each statement within a block is terminated by a 
semicolon. A block that appears within another block must have a semicolon 
after `END`, as shown above; however the final `END` that concludes a function 
body does not require a semicolon.
+
+You can specify all key words and identifiers in mixed upper and lower 
case. Identifiers are implicitly converted to lowercase unless double-quoted.
+
+PL/pgSQL supports two types of comments. A double dash (`--`) starts a 
comment that extends to the end of the line. A `/*` starts a block comment that 
extends to the next occurrence of `*/`. Block comments cannot be nested, but 
you can enclose double dash comments into a block comment and a double dash can 
hide the block comment delimiters `/*` and `*/`.
+
+This example PL/pgSQL function adds thirteen to an integer:
 

[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread dyozie
Github user dyozie commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105444745
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,278 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+PL/pgSQL does not have these limitations. When creating functions with the 
PL/pgSQL language, you can group computation blocks and queries inside the 
database server, combining the power of a procedural language and the ease of 
use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   You avoid multiple rounds of query parsing
+ 
 
-With PL/pgSQL, you can group a block of computation and a series of 
queries inside the database server, thus having the power of a procedural 
language and the ease of use of SQL, but with considerable savings of 
client/server communication overhead.
+## PL/pgSQL Function Syntax
 
--   Extra round trips between client and server are eliminated
--   Intermediate results that the client does not need do not have to be 
marshaled or transferred between server and client
--   Multiple rounds of query parsing can be avoided
+PL/pgSQL is a block-structured language. The complete text of a function 
definition must be a block, which is defined as:
 
-This can result in a considerable performance increase as compared to an 
application that does not use stored functions.
+``` sql
+[  ]
+[ DECLARE
+declarations ]
+BEGIN
+statements
+END [ label ];
+```
 
-PL/pgSQL supports all the data types, operators, and functions of SQL.
+Each declaration and each statement within a block is terminated by a 
semicolon. A block that appears within another block must have a semicolon 
after `END`, as shown above; however the final `END` that concludes a function 
body does not require a semicolon.
+
+You can specify all key words and identifiers in mixed upper and lower 
case. Identifiers are implicitly converted to lowercase unless double-quoted.
+
+PL/pgSQL supports two types of comments. A double dash (`--`) starts a 
comment that extends to the end of the line. A `/*` starts a block comment that 
extends to the next occurrence of `*/`. Block comments cannot be nested, but 
you can enclose double dash comments into a block comment and a double dash can 
hide the block comment delimiters `/*` and `*/`.
+
+This example PL/pgSQL function adds thirteen to an integer:
 

[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread dyozie
Github user dyozie commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105446890
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,278 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+PL/pgSQL does not have these limitations. When creating functions with the 
PL/pgSQL language, you can group computation blocks and queries inside the 
database server, combining the power of a procedural language and the ease of 
use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   You avoid multiple rounds of query parsing
+ 
 
-With PL/pgSQL, you can group a block of computation and a series of 
queries inside the database server, thus having the power of a procedural 
language and the ease of use of SQL, but with considerable savings of 
client/server communication overhead.
+## PL/pgSQL Function Syntax
 
--   Extra round trips between client and server are eliminated
--   Intermediate results that the client does not need do not have to be 
marshaled or transferred between server and client
--   Multiple rounds of query parsing can be avoided
+PL/pgSQL is a block-structured language. The complete text of a function 
definition must be a block, which is defined as:
 
-This can result in a considerable performance increase as compared to an 
application that does not use stored functions.
+``` sql
+[  ]
+[ DECLARE
+declarations ]
+BEGIN
+statements
+END [ label ];
+```
 
-PL/pgSQL supports all the data types, operators, and functions of SQL.
+Each declaration and each statement within a block is terminated by a 
semicolon. A block that appears within another block must have a semicolon 
after `END`, as shown above; however the final `END` that concludes a function 
body does not require a semicolon.
+
+You can specify all key words and identifiers in mixed upper and lower 
case. Identifiers are implicitly converted to lowercase unless double-quoted.
+
+PL/pgSQL supports two types of comments. A double dash (`--`) starts a 
comment that extends to the end of the line. A `/*` starts a block comment that 
extends to the next occurrence of `*/`. Block comments cannot be nested, but 
you can enclose double dash comments into a block comment and a double dash can 
hide the block comment delimiters `/*` and `*/`.
+
+This example PL/pgSQL function adds thirteen to an integer:
 

[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread dyozie
Github user dyozie commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105445495
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,278 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+PL/pgSQL does not have these limitations. When creating functions with the 
PL/pgSQL language, you can group computation blocks and queries inside the 
database server, combining the power of a procedural language and the ease of 
use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   You avoid multiple rounds of query parsing
+ 
 
-With PL/pgSQL, you can group a block of computation and a series of 
queries inside the database server, thus having the power of a procedural 
language and the ease of use of SQL, but with considerable savings of 
client/server communication overhead.
+## PL/pgSQL Function Syntax
 
--   Extra round trips between client and server are eliminated
--   Intermediate results that the client does not need do not have to be 
marshaled or transferred between server and client
--   Multiple rounds of query parsing can be avoided
+PL/pgSQL is a block-structured language. The complete text of a function 
definition must be a block, which is defined as:
 
-This can result in a considerable performance increase as compared to an 
application that does not use stored functions.
+``` sql
+[  ]
+[ DECLARE
+declarations ]
+BEGIN
+statements
+END [ label ];
+```
 
-PL/pgSQL supports all the data types, operators, and functions of SQL.
+Each declaration and each statement within a block is terminated by a 
semicolon. A block that appears within another block must have a semicolon 
after `END`, as shown above; however the final `END` that concludes a function 
body does not require a semicolon.
+
+You can specify all key words and identifiers in mixed upper and lower 
case. Identifiers are implicitly converted to lowercase unless double-quoted.
+
+PL/pgSQL supports two types of comments. A double dash (`--`) starts a 
comment that extends to the end of the line. A `/*` starts a block comment that 
extends to the next occurrence of `*/`. Block comments cannot be nested, but 
you can enclose double dash comments into a block comment and a double dash can 
hide the block comment delimiters `/*` and `*/`.
+
+This example PL/pgSQL function adds thirteen to an integer:
 

[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread dyozie
Github user dyozie commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105444363
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,278 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+PL/pgSQL does not have these limitations. When creating functions with the 
PL/pgSQL language, you can group computation blocks and queries inside the 
database server, combining the power of a procedural language and the ease of 
use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   You avoid multiple rounds of query parsing
+ 
 
-With PL/pgSQL, you can group a block of computation and a series of 
queries inside the database server, thus having the power of a procedural 
language and the ease of use of SQL, but with considerable savings of 
client/server communication overhead.
+## PL/pgSQL Function Syntax
 
--   Extra round trips between client and server are eliminated
--   Intermediate results that the client does not need do not have to be 
marshaled or transferred between server and client
--   Multiple rounds of query parsing can be avoided
+PL/pgSQL is a block-structured language. The complete text of a function 
definition must be a block, which is defined as:
 
-This can result in a considerable performance increase as compared to an 
application that does not use stored functions.
+``` sql
+[  ]
+[ DECLARE
+declarations ]
+BEGIN
+statements
+END [ label ];
+```
 
-PL/pgSQL supports all the data types, operators, and functions of SQL.
+Each declaration and each statement within a block is terminated by a 
semicolon. A block that appears within another block must have a semicolon 
after `END`, as shown above; however the final `END` that concludes a function 
body does not require a semicolon.
+
+You can specify all key words and identifiers in mixed upper and lower 
case. Identifiers are implicitly converted to lowercase unless double-quoted.
+
+PL/pgSQL supports two types of comments. A double dash (`--`) starts a 
comment that extends to the end of the line. A `/*` starts a block comment that 
extends to the next occurrence of `*/`. Block comments cannot be nested, but 
you can enclose double dash comments into a block comment and a double dash can 
hide the block comment delimiters `/*` and `*/`.
+
+This example PL/pgSQL function adds thirteen to an integer:
 

[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread dyozie
Github user dyozie commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105448115
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,278 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+PL/pgSQL does not have these limitations. When creating functions with the 
PL/pgSQL language, you can group computation blocks and queries inside the 
database server, combining the power of a procedural language and the ease of 
use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   You avoid multiple rounds of query parsing
+ 
 
-With PL/pgSQL, you can group a block of computation and a series of 
queries inside the database server, thus having the power of a procedural 
language and the ease of use of SQL, but with considerable savings of 
client/server communication overhead.
+## PL/pgSQL Function Syntax
 
--   Extra round trips between client and server are eliminated
--   Intermediate results that the client does not need do not have to be 
marshaled or transferred between server and client
--   Multiple rounds of query parsing can be avoided
+PL/pgSQL is a block-structured language. The complete text of a function 
definition must be a block, which is defined as:
 
-This can result in a considerable performance increase as compared to an 
application that does not use stored functions.
+``` sql
+[  ]
+[ DECLARE
+declarations ]
+BEGIN
+statements
+END [ label ];
+```
 
-PL/pgSQL supports all the data types, operators, and functions of SQL.
+Each declaration and each statement within a block is terminated by a 
semicolon. A block that appears within another block must have a semicolon 
after `END`, as shown above; however the final `END` that concludes a function 
body does not require a semicolon.
+
+You can specify all key words and identifiers in mixed upper and lower 
case. Identifiers are implicitly converted to lowercase unless double-quoted.
+
+PL/pgSQL supports two types of comments. A double dash (`--`) starts a 
comment that extends to the end of the line. A `/*` starts a block comment that 
extends to the next occurrence of `*/`. Block comments cannot be nested, but 
you can enclose double dash comments into a block comment and a double dash can 
hide the block comment delimiters `/*` and `*/`.
+
+This example PL/pgSQL function adds thirteen to an integer:
 

[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread dyozie
Github user dyozie commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105436546
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,278 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+PL/pgSQL does not have these limitations. When creating functions with the 
PL/pgSQL language, you can group computation blocks and queries inside the 
database server, combining the power of a procedural language and the ease of 
use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
--- End diff --

I see what you mean here, but am concerned about the blanket statement 
"Pl/pgsql does not have these limitations."  You're comparing db-executed 
functions with a client/server architecture, but the above statement is 
contrasting with a very general statement about SQL itself.  I don't think 
pgsql gets you around any inherent limitations of SQL as you've stated them.

I guess my concern comes from the recent limitations added regarding cursor 
support in PL languages.  It's natural to assume you can open a cursor and move 
through a query directly in the language, but really the cursor operations (and 
other SQL) are still exec'd on the db.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread dyozie
Github user dyozie commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105447834
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,278 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+PL/pgSQL does not have these limitations. When creating functions with the 
PL/pgSQL language, you can group computation blocks and queries inside the 
database server, combining the power of a procedural language and the ease of 
use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   You avoid multiple rounds of query parsing
+ 
 
-With PL/pgSQL, you can group a block of computation and a series of 
queries inside the database server, thus having the power of a procedural 
language and the ease of use of SQL, but with considerable savings of 
client/server communication overhead.
+## PL/pgSQL Function Syntax
 
--   Extra round trips between client and server are eliminated
--   Intermediate results that the client does not need do not have to be 
marshaled or transferred between server and client
--   Multiple rounds of query parsing can be avoided
+PL/pgSQL is a block-structured language. The complete text of a function 
definition must be a block, which is defined as:
 
-This can result in a considerable performance increase as compared to an 
application that does not use stored functions.
+``` sql
+[  ]
+[ DECLARE
+declarations ]
+BEGIN
+statements
+END [ label ];
+```
 
-PL/pgSQL supports all the data types, operators, and functions of SQL.
+Each declaration and each statement within a block is terminated by a 
semicolon. A block that appears within another block must have a semicolon 
after `END`, as shown above; however the final `END` that concludes a function 
body does not require a semicolon.
+
+You can specify all key words and identifiers in mixed upper and lower 
case. Identifiers are implicitly converted to lowercase unless double-quoted.
+
+PL/pgSQL supports two types of comments. A double dash (`--`) starts a 
comment that extends to the end of the line. A `/*` starts a block comment that 
extends to the next occurrence of `*/`. Block comments cannot be nested, but 
you can enclose double dash comments into a block comment and a double dash can 
hide the block comment delimiters `/*` and `*/`.
+
+This example PL/pgSQL function adds thirteen to an integer:
 

[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread dyozie
Github user dyozie commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105438584
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,278 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+PL/pgSQL does not have these limitations. When creating functions with the 
PL/pgSQL language, you can group computation blocks and queries inside the 
database server, combining the power of a procedural language and the ease of 
use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   You avoid multiple rounds of query parsing
+ 
 
-With PL/pgSQL, you can group a block of computation and a series of 
queries inside the database server, thus having the power of a procedural 
language and the ease of use of SQL, but with considerable savings of 
client/server communication overhead.
+## PL/pgSQL Function Syntax
 
--   Extra round trips between client and server are eliminated
--   Intermediate results that the client does not need do not have to be 
marshaled or transferred between server and client
--   Multiple rounds of query parsing can be avoided
+PL/pgSQL is a block-structured language. The complete text of a function 
definition must be a block, which is defined as:
 
-This can result in a considerable performance increase as compared to an 
application that does not use stored functions.
+``` sql
+[  ]
+[ DECLARE
+declarations ]
+BEGIN
+statements
+END [ label ];
+```
 
-PL/pgSQL supports all the data types, operators, and functions of SQL.
+Each declaration and each statement within a block is terminated by a 
semicolon. A block that appears within another block must have a semicolon 
after `END`, as shown above; however the final `END` that concludes a function 
body does not require a semicolon.
+
+You can specify all key words and identifiers in mixed upper and lower 
case. Identifiers are implicitly converted to lowercase unless double-quoted.
+
+PL/pgSQL supports two types of comments. A double dash (`--`) starts a 
comment that extends to the end of the line. A `/*` starts a block comment that 
extends to the next occurrence of `*/`. Block comments cannot be nested, but 
you can enclose double dash comments into a block comment and a double dash can 
hide the block comment delimiters `/*` and `*/`.
+
+This example PL/pgSQL function adds thirteen to an integer:
 

[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread dyozie
Github user dyozie commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105436857
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,278 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+PL/pgSQL does not have these limitations. When creating functions with the 
PL/pgSQL language, you can group computation blocks and queries inside the 
database server, combining the power of a procedural language and the ease of 
use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   You avoid multiple rounds of query parsing
--- End diff --

Maybe edit to "Re-using prepared queries avoids multiple..."


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-10 Thread dyozie
Github user dyozie commented on a diff in the pull request:

https://github.com/apache/incubator-hawq-docs/pull/101#discussion_r105437227
  
--- Diff: markdown/plext/using_plpgsql.html.md.erb ---
@@ -19,143 +19,278 @@ software distributed under the License is distributed 
on an
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
--->
+--> 
 
-SQL is the language of most other relational databases use as query 
language. It is portable and easy to learn. But every SQL statement must be 
executed individually by the database server. 
+PL/pgSQL is a trusted procedural language that is automatically installed 
and registered in all HAWQ databases. With PL/pgSQL, you can:
 
-PL/pgSQL is a loadable procedural language. PL/SQL can do the following:
+-   Create functions
+-   Add control structures to the SQL language
+-   Perform complex computations
+-   Use all of the data types, functions, and operators defined in SQL
 
--   create functions
--   add control structures to the SQL language
--   perform complex computations
--   inherit all user-defined types, functions, and operators
--   be trusted by the server
+SQL is the language most relational databases use as a query language. 
While it is portable and easy to learn, every SQL statement is individually 
executed by the database server. Your client application sends each query to 
the database server, waits for it to be processed, receives and processes the 
results, does some computation, then sends further queries to the server. This 
back-and-forth requires interprocess communication and incurs network overhead 
if your client is on a different host than the HAWQ master.
 
-You can use functions created with PL/pgSQL with any database that 
supports built-in functions. For example, it is possible to create complex 
conditional computation functions and later use them to define operators or use 
them in index expressions.
+PL/pgSQL does not have these limitations. When creating functions with the 
PL/pgSQL language, you can group computation blocks and queries inside the 
database server, combining the power of a procedural language and the ease of 
use of SQL, but with considerable savings of client/server communication 
overhead. With PL/pgSQL:
 
-Every SQL statement must be executed individually by the database server. 
Your client application must send each query to the database server, wait for 
it to be processed, receive and process the results, do some computation, then 
send further queries to the server. This requires interprocess communication 
and incurs network overhead if your client is on a different machine than the 
database server.
+-   Extra round trips between client and server are eliminated
+-   Intermediate, and perhaps unneeded, results do not have to be 
marshaled or transferred between the server and client
+-   You avoid multiple rounds of query parsing
+ 
 
-With PL/pgSQL, you can group a block of computation and a series of 
queries inside the database server, thus having the power of a procedural 
language and the ease of use of SQL, but with considerable savings of 
client/server communication overhead.
+## PL/pgSQL Function Syntax
 
--   Extra round trips between client and server are eliminated
--   Intermediate results that the client does not need do not have to be 
marshaled or transferred between server and client
--   Multiple rounds of query parsing can be avoided
+PL/pgSQL is a block-structured language. The complete text of a function 
definition must be a block, which is defined as:
 
-This can result in a considerable performance increase as compared to an 
application that does not use stored functions.
+``` sql
+[  ]
+[ DECLARE
+declarations ]
+BEGIN
+statements
+END [ label ];
+```
 
-PL/pgSQL supports all the data types, operators, and functions of SQL.
+Each declaration and each statement within a block is terminated by a 
semicolon. A block that appears within another block must have a semicolon 
after `END`, as shown above; however the final `END` that concludes a function 
body does not require a semicolon.
+
+You can specify all key words and identifiers in mixed upper and lower 
case. Identifiers are implicitly converted to lowercase unless double-quoted.
--- End diff --

edit:  "unless **they are** double-quoted."


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] incubator-hawq-docs pull request #101: HAWQ-1383 - plpgsql page cleanup, res...

2017-03-09 Thread lisakowen
GitHub user lisakowen opened a pull request:

https://github.com/apache/incubator-hawq-docs/pull/101

HAWQ-1383 - plpgsql page cleanup, restructure, more examples

many changes to the plpgsql page:
- restructured and added some general info 
- added links to postgres docs where appropriate
- added several concepts sections with examples
- moved polymorphic types section to data types page.  also pared down the 
info, hawq doesn't appear to support anynonarray and anyenum
- added polymorphic example
- removed variadic function argument section - tried several incantations 
and couldn't get it to work.  either hawq doesn't support variadic functions 
(hard to tell from the code) or user error.  if the latter i can add a 
section/example back in.


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/lisakowen/incubator-hawq-docs 
feature/HAWQ-1383-plpgsql-cleanup

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/incubator-hawq-docs/pull/101.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #101


commit d48c238a690a3e102f789a01e9ea3e6e62861310
Author: Lisa Owen 
Date:   2017-03-09T02:49:31Z

HAWQ-1383 - plpgsql page cleanup, restructure, more examples




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---