hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject [3/7] incubator-hawq-docs git commit: HAWQ-1251 Add CREATE CAST/CONVERSION pages to documentation (closes #85)
Date Fri, 20 Jan 2017 16:41:42 GMT
HAWQ-1251 Add CREATE CAST/CONVERSION pages to documentation (closes #85)


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq-docs/commit/e04f7f89
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq-docs/tree/e04f7f89
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq-docs/diff/e04f7f89

Branch: refs/heads/release/2.1.0.0-incubating
Commit: e04f7f89ded867efb3ab4fc15e7aa2e8d063232e
Parents: 04bf221
Author: Jane Beckman <jbeckman@pivotal.io>
Authored: Fri Jan 13 15:46:53 2017 -0800
Committer: David Yozie <yozie@apache.org>
Committed: Fri Jan 13 15:46:53 2017 -0800

----------------------------------------------------------------------
 .../source/subnavs/apache-hawq-nav-210.erb      |  5 +
 .../reference/sql/ALTER-CONVERSION.html.md.erb  | 56 ++++++++++++
 markdown/reference/sql/CREATE-CAST.html.md.erb  | 96 ++++++++++++++++++++
 .../reference/sql/CREATE-CONVERSION.html.md.erb | 67 ++++++++++++++
 markdown/reference/sql/DROP-CAST.html.md.erb    | 48 ++++++++++
 .../reference/sql/DROP-CONVERSION.html.md.erb   | 48 ++++++++++
 6 files changed, 320 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq-docs/blob/e04f7f89/book/master_middleman/source/subnavs/apache-hawq-nav-210.erb
----------------------------------------------------------------------
diff --git a/book/master_middleman/source/subnavs/apache-hawq-nav-210.erb b/book/master_middleman/source/subnavs/apache-hawq-nav-210.erb
index 1c7449f..5d0306f 100644
--- a/book/master_middleman/source/subnavs/apache-hawq-nav-210.erb
+++ b/book/master_middleman/source/subnavs/apache-hawq-nav-210.erb
@@ -692,6 +692,7 @@
             <ul>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/ABORT.html">ABORT</a></li>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/ALTER-AGGREGATE.html">ALTER
AGGREGATE</a></li>
+              <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/ALTER-CONVERSION.html">ALTER
CONVERSION</a></li>  
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/ALTER-DATABASE.html">ALTER
DATABASE</a></li>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/ALTER-FUNCTION.html">ALTER
FUNCTION</a></li>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/ALTER-OPERATOR.html">ALTER
OPERATOR</a></li>
@@ -709,6 +710,8 @@
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/COMMIT.html">COMMIT</a></li>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/COPY.html">COPY</a></li>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/CREATE-AGGREGATE.html">CREATE
AGGREGATE</a></li>
+              <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/CREATE-CAST.html">CREATE
CAST</a></li>
+              <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/CREATE-CONVERSION.html">CREATE
CONVERSION</a></li>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/CREATE-DATABASE.html">CREATE
DATABASE</a></li>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/CREATE-EXTERNAL-TABLE.html">CREATE
EXTERNAL TABLE</a></li>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/CREATE-FUNCTION.html">CREATE
FUNCTION</a></li>
@@ -729,6 +732,8 @@
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/DEALLOCATE.html">DEALLOCATE</a></li>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/DECLARE.html">DECLARE</a></li>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/DROP-AGGREGATE.html">DROP
AGGREGATE</a></li>
+              <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/DROP-CAST.html">DROP
CAST</a></li>
+              <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/DROP-CONVERSION.html">DROP
CONVERSION</a></li>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/DROP-DATABASE.html">DROP
DATABASE</a></li>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/DROP-EXTERNAL-TABLE.html">DROP
EXTERNAL TABLE</a></li>
               <li><a href="/docs/userguide/2.1.0.0-incubating/reference/sql/DROP-FILESPACE.html">DROP
FILESPACE</a></li>

http://git-wip-us.apache.org/repos/asf/incubator-hawq-docs/blob/e04f7f89/markdown/reference/sql/ALTER-CONVERSION.html.md.erb
----------------------------------------------------------------------
diff --git a/markdown/reference/sql/ALTER-CONVERSION.html.md.erb b/markdown/reference/sql/ALTER-CONVERSION.html.md.erb
new file mode 100644
index 0000000..5b02ffc
--- /dev/null
+++ b/markdown/reference/sql/ALTER-CONVERSION.html.md.erb
@@ -0,0 +1,56 @@
+---
+title: ALTER CONVERSION
+---
+
+Changes the definition of a CONVERSION.
+
+## <a id="topic1__section2"></a>Synopsis
+
+``` pre
+ALTER CONVERSION <name> RENAME TO <newname>
+
+ALTER CONVERSION <name> OWNER TO <newowner>
+```
+
+## <a id="topic1__section3"></a>Description
+
+`ALTER CONVERSION` changes the definition of a conversion. 
+
+You must own the conversion to use `ALTER CONVERSION`. To alter the owner, you must also
be a direct or indirect member of the new owning role, and that role must have `CREATE` privilege
on the conversion's schema. (These restrictions enforce that altering the owner does not do
anything you could not do by dropping and recreating the conversion. However, a superuser
can always alter ownership of any conversion.).
+
+## <a id="topic1__section4"></a>Parameters
+
+<dt>\<name\>   </dt>
+<dd>The (optionally schema-qualified) name of an existing conversion.</dd>
+
+<dt>\<newname\>  </dt>
+<dd>The new name of the conversion.</dd>
+
+<dt>\<newowner\>  </dt>
+<dd>The new owner of the conversion.</dd>
+
+
+## <a id="topic1__section5"></a>Examples
+
+To rename the conversion `iso_8859_1_to_utf8` to `latin1_to_unicode`:
+
+``` pre
+ALTER CONVERSION iso_8859_1_to_utf8 RENAME TO 
+latin1_to_unicode;
+```
+
+To change the owner of the conversion `iso_8859_1_to_utf8` to `joe`:
+
+``` pre
+ALTER CONVERSION iso_8859_1_to_utf8 OWNER TO joe;
+```
+
+## <a id="topic1__section6"></a>Compatibility
+
+There is no ALTER CONVERSION statement in the SQL standard.
+
+## <a id="topic1__section7"></a>See Also
+
+[CREATE CONVERSION](CREATE-CONVERSION.html), [DROP CONVERSION](DROP-CONVERSION.html)
+
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq-docs/blob/e04f7f89/markdown/reference/sql/CREATE-CAST.html.md.erb
----------------------------------------------------------------------
diff --git a/markdown/reference/sql/CREATE-CAST.html.md.erb b/markdown/reference/sql/CREATE-CAST.html.md.erb
new file mode 100644
index 0000000..af35173
--- /dev/null
+++ b/markdown/reference/sql/CREATE-CAST.html.md.erb
@@ -0,0 +1,96 @@
+---
+title: CREATE CAST
+---
+
+Defines a new cast.
+
+## <a id="topic1__section2"></a>Synopsis
+
+``` pre
+CREATE CAST (<sourcetype> AS <targettype>) 
+       WITH FUNCTION <funcname (argtypes)> 
+       [AS ASSIGNMENT | AS IMPLICIT]
+
+CREATE CAST (<sourcetype> AS <targettype>) WITHOUT FUNCTION 
+       [AS ASSIGNMENT | AS IMPLICIT]
+```
+
+## <a id="topic1__section3"></a>Description
+
+`CREATE CAST` defines a new cast. A cast specifies how to perform a conversion between two
data types. For example,
+
+```pre
+SELECT CAST(42 AS text);
+```
+
+converts the integer constant `42` to type `text` by invoking a previously specified function,
in this case `text(int4)`. If no suitable cast has been defined, the conversion fails.
+
+Two types may be binary compatible, which means that they can be converted into one another
without invoking any function. This requires that corresponding values use the same internal
representation. For instance, the types `text` and `varchar` are binary compatible.
+
+By default, a cast can be invoked only by an explicit cast request, that is an explicit `CAST(x
AS typename)` or `x:: typename` construct.
+
+If the cast is marked `AS ASSIGNMENT` then it can be invoked implicitly when assigning a
value to a column of the target data type. For example, supposing that `foo.f1` is a column
of type `text`, then:
+
+``` pre
+INSERT INTO foo (f1) VALUES (42);
+```
+will be allowed if the cast from type integer to type `text` is marked `AS ASSIGNMENT`, otherwise
not. The term *assignment cast* is typically used to describe this kind of cast.
+
+If the cast is marked `AS IMPLICIT` then it can be invoked implicitly in any context, whether
by assignment or internally in an expression. The term *implicit cast* is typically used to
describe this kind of cast. For example, since `||` takes `text` operands,
+
+``` pre
+SELECT 'The time is ' || now();
+```
+It is wise to be conservative about marking casts `AS IMPLICIT`. An overabundance of implicit
casting paths can cause HAWQ to choose surprising interpretations of commands, or to be unable
to resolve commands at all because there are multiple possible interpretations. A good rule
of thumb is to make a cast implicitly invokable only for information-preserving transformations
between types in the same general type category. For example, the cast from `int2` to `int4`
can reasonably be implicit, but the cast from `float8` to `int4` should probably be assignment-only.
Cross-type-category casts, such as `text` to `int4`, are best made explicit-only.
+
+To be able to create a cast, you must own the source or the target data type. To create a
binary-compatible cast, you must be superuser.
+
+
+## <a id="topic1__section4"></a>Parameters
+
+<dt>\<sourcetype\>  </dt>
+<dd>The name of the source data type of the cast.</dd>
+
+<dt>\<targettype\>  </dt>
+<dd>The name of the target data type of the cast.</dd>
+
+<dt> \<funcname(argtypes)\>   </dt>
+<dd>The function used to perform the cast. The function name may be schema-qualified.
If it is not, the function is looked up in the schema search path. The function's result data
type must match the target type of the cast.
+Cast implementation functions may have one to three arguments. The first argument type must
be identical to the cast's source type. The second argument, if present, must be type `integer`;
it receives the type modifier associated with the destination type, or `-1` if there is none.
The third argument, if present, must be type `boolean`; it receives `true` if the cast is
an explicit cast, `false` otherwise. In some cases, the SQL specification demands different
behaviors for explicit and implicit casts. This argument is supplied for functions that must
implement such casts. Designing  your own data types this way is not recommended.
+Ordinarily, a cast must have different source and target data types. However, declaring a
cast with identical source and target types is allowed if it has a cast implementation function
with more than one argument. This is used to represent type-specific length coercion functions
in the system catalogs. The named function is used to coerce a value of the type to the type
modifier value specified by its second argument. (Since the grammar presently permits only
certain built-in data types to have type modifiers, this feature is of no use for user-defined
target types.)
+When a cast has different source and target types and a function that takes more than one
argument, it represents a conversion from one type to another and applying a length coercion
in a single step. When no such entry is available, coercion to a type that uses a type modifier
involves two steps, one to convert between data types and a second to apply the modifier.
+</dd>
+
+<dt>WITHOUT FUNCTION</dt>
+<dd>Indicates that the source type and the target type are binary compatible, so no
function is required to perform the cast.</dd>
+
+<dt>AS ASSIGNMENT </dt>
+<dd>Indicates that the cast may be invoked implicitly in assignment contexts.</dd>
+
+<dt>AS IMPLICIT  </dt>
+<dd>Indicates that the cast may be invoked implicitly in any context.</dd>
+
+## <a id="topic1__section5"></a>Notes
+
+For this release of HAWQ, user-defined functions used in a user-defined cast must be defined
as `IMMUTABLE`. Any compiled code (shared library files) for custom functions must be placed
in the same location on every host in your HAWQ array (master and all segments). This location
must also be in the `LD_LIBRARY_PATH` so that the server can locate the files.
+
+Remember that if you want to be able to convert types both ways, you need to declare casts
both ways explicitly.
+
+We recommend that you follow the convention of naming cast implementation functions after
the target data type, as the built-in cast implementation functions are named. Many users
are used to being able to cast data types using a function-style notation, that is `typename(x)`.
+
+## <a id="topic1__section6"></a>Examples
+
+Create a cast from type `text` to type `int4` using the function `int4(text)`. (This cast
is already predefined in the system.):
+
+``` pre
+CREATE CAST (text AS int4) WITH FUNCTION int4(text);
+```
+
+## <a id="topic1__section7"></a>Compatibility
+
+The `CREATE CAST` command conforms to the SQL standard, except that SQL does not make provisions
for binary-compatible types or extra arguments to implementation functions. `AS IMPLICIT`
is also a HAWQ extension.
+
+## <a id="topic1__section8"></a>See Also
+
+[DROP CAST](DROP-CAST.html),  [CREATE FUNCTION](CREATE-FUNCTION.html)
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq-docs/blob/e04f7f89/markdown/reference/sql/CREATE-CONVERSION.html.md.erb
----------------------------------------------------------------------
diff --git a/markdown/reference/sql/CREATE-CONVERSION.html.md.erb b/markdown/reference/sql/CREATE-CONVERSION.html.md.erb
new file mode 100644
index 0000000..5bc7910
--- /dev/null
+++ b/markdown/reference/sql/CREATE-CONVERSION.html.md.erb
@@ -0,0 +1,67 @@
+---
+title: CREATE CONVERSION
+---
+
+Defines a new encoding conversion.
+
+## <a id="topic1__section2"></a>Synopsis
+
+``` pre
+CREATE [DEFAULT] CONVERSION <name> FOR <source_encoding> TO 
+     <dest_encoding> FROM <funcname>
+```
+
+## <a id="topic1__section3"></a>Description
+
+`CREATE CONVERSION` defines a new conversion between character set encodings. Conversion
names may be used in the convert function to specify a particular encoding conversion. Also,
conversions that are marked `DEFAULT` can be used for automatic encoding conversion between
client and server. For this purpose, two conversions, from encoding A to B and from encoding
B to A, must be defined.
+
+To create a conversion, you must have `EXECUTE` privilege on the function and `CREATE` privilege
on the destination schema.
+
+
+## <a id="topic1__section4"></a>Parameters
+
+<dt>DEFAULT</dt>
+<dd>Indicates that this conversion is the default for this particular source to destination
encoding. There should be only one default encoding in a schema for the encoding pair.</dd>
+
+<dt>\<name\>  </dt>
+<dd>The name of the conversion. The conversion name may be schema-qualified. If it
is not, the conversion is defined in the current schema. The conversion name must be unique
within a schema.</dd>
+
+<dt>\<source_encoding\>  </dt>
+<dd>The source encoding name.</dd>
+
+<dt>\<dest_encoding\>  </dt>
+<dd>The destination encoding name.</dd>
+
+<dt>\<funcname\>  </dt>
+<dd>The function used to perform the conversion. The function name may be schema-qualified.
If it is not, the function will be looked up in the path. The function must have the following
signature:</dd>
+
+``` pre
+conv_proc(
+    integer,  -- source encoding ID
+    integer,  -- destination encoding ID
+    cstring,  -- source string (null terminated C string)
+    internal, -- destination (fill with a null terminated C string)
+    integer   -- source string length
+) RETURNS void;
+```
+
+## <a id="topic1__section5"></a>Notes
+
+For this release of HAWQ, user-defined functions used in a user-defined cast must be defined
as `IMMUTABLE`. Any compiled code (shared library files) for custom functions must be placed
in the same location on every host in your HAWQ array (master and all segments). This location
must also be in the `LD_LIBRARY_PATH` so that the server can locate the files.
+
+
+## <a id="topic1__section6"></a>Examples
+
+To create a conversion from encoding `UTF8` to `LATIN1` using `myfunc`:
+
+``` pre
+CREATE CONVERSION myconv FOR 'UTF8' TO 'LATIN1' FROM myfunc;
+```
+
+## <a id="topic1__section7"></a>Compatibility
+
+There is no CREATE CONVERSION statement in the SQL standard.
+
+## <a id="topic1__section8"></a>See Also
+
+[DROP CONVERSION](DROP-CONVERSION.html), [CREATE FUNCTION](CREATE-FUNCTION.html)

http://git-wip-us.apache.org/repos/asf/incubator-hawq-docs/blob/e04f7f89/markdown/reference/sql/DROP-CAST.html.md.erb
----------------------------------------------------------------------
diff --git a/markdown/reference/sql/DROP-CAST.html.md.erb b/markdown/reference/sql/DROP-CAST.html.md.erb
new file mode 100644
index 0000000..dd8e928
--- /dev/null
+++ b/markdown/reference/sql/DROP-CAST.html.md.erb
@@ -0,0 +1,48 @@
+---
+title: DROP CAST
+---
+
+Removes a cast.
+
+## <a id="topic1__section2"></a>Synopsis
+
+``` pre
+DROP CAST [IF EXISTS] (<sourcetype> AS <targettype>) [CASCADE | RESTRICT]
+```
+
+## <a id="topic1__section3"></a>Description
+
+`DROP CAST` will delete a previously defined cast. To be able to drop a cast, you must own
the source or the target data type. These are the same privileges that are required to create
a cast.
+
+## <a id="topic1__section4"></a>Parameters
+
+<dt>IF EXISTS </dt>
+<dd>Do not throw an error if the cast does not exist. A notice is issued in this case.</dd>
+
+<dt>\<sourcetype\> </dt>
+<dd>The name of the source data type of the cast to be removed.</dd>
+
+<dt>\<targettype\> </dt>
+<dd>The name of the target data type of the cast to be removed.</dd>
+
+<dt>CASCADE</dt>
+<dt>RESTRICT</dt>
+<dd>These keywords have no effect since there are no dependencies on casts.</dd>
+
+## <a id="topic1__section5"></a>Examples
+
+To drop the cast from type `text` to type `int`:
+
+``` pre
+DROP CAST (text AS int);
+```
+
+## <a id="topic1__section6"></a>Compatibility
+
+The `DROP CAST` command conforms to the SQL standard.
+
+## <a id="topic1__section7"></a>See Also
+
+[CREATE CAST](CREATE-CAST.html)
+
+

http://git-wip-us.apache.org/repos/asf/incubator-hawq-docs/blob/e04f7f89/markdown/reference/sql/DROP-CONVERSION.html.md.erb
----------------------------------------------------------------------
diff --git a/markdown/reference/sql/DROP-CONVERSION.html.md.erb b/markdown/reference/sql/DROP-CONVERSION.html.md.erb
new file mode 100644
index 0000000..d435417
--- /dev/null
+++ b/markdown/reference/sql/DROP-CONVERSION.html.md.erb
@@ -0,0 +1,48 @@
+---
+title: DROP CONVERSION
+---
+
+Removes a CONVERSION.
+
+## <a id="topic1__section2"></a>Synopsis
+
+``` pre
+DROP CONVERSION [IF EXISTS] <name> [CASCADE | RESTRICT]
+```
+
+## <a id="topic1__section3"></a>Description
+
+`DROP CONVERSION` removes a previously defined conversion. To be able to drop a conversion,
you must own the conversion.
+
+## <a id="topic1__section4"></a>Parameters
+
+<dt>IF EXISTS  </dt>
+<dd>Do not throw an error if the conversion does not exist. A notice is issued in this
case.</dd>
+
+<dt>\<name\>   </dt>
+<dd>The name of the conversion.  The conversion name may be schema-qualified.</dd>
+
+<dt>\<targettype\>   </dt>
+<dd>The name of the target data type of the cast to be removed.</dd>
+
+<dt>CASCADE</dt>
+<dt>RESTRICT</dt>
+<dd>These keywords have no effect since there are no dependencies on conversions.</dd>
+
+## <a id="topic1__section5"></a>Examples
+
+Drop the conversion named `myname`:
+
+``` pre
+DROP CONVERSION myname;
+```
+
+## <a id="topic1__section6"></a>Compatibility
+
+There is no `DROP CONVERSION` statement in the SQL standard.
+
+## <a id="topic1__section7"></a>See Also
+
+[CREATE CONVERSION](CREATE-CONVERSION.html), [ALTER CONVERSION](ALTER-CONVERSION.html)
+
+


Mime
View raw message