Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d31736e

Browse files
committed
Doc updates from Darren on char2-16 removal
1 parent 0d203b7 commit d31736e

File tree

6 files changed

+35
-48
lines changed

6 files changed

+35
-48
lines changed

doc/FAQ

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ Section 3: PostgreSQL Features
543543
jolly=>
544544

545545
The fields in pg_group are:
546-
* groname: the group name. This a char16 and should be purely
546+
* groname: the group name. This a name and should be purely
547547
alphanumeric. Do not include underscores or other punctuation.
548548
* grosysid: the group id. This is an int4. This should be unique for
549549
each group.
@@ -622,11 +622,7 @@ Section 3: PostgreSQL Features
622622

623623
Type Internal Name Notes
624624
--------------------------------------------------
625-
CHAR char 1 character }
626-
CHAR2 char2 2 characters }
627-
CHAR4 char4 4 characters } optimized for a fixed length
628-
CHAR8 char8 8 characters }
629-
CHAR16 char16 16 characters }
625+
CHAR char 1 character
630626
CHAR(#) bpchar blank padded to the specified fixed length
631627
VARCHAR(#) varchar size specifies maximum length, no padding
632628
TEXT text length limited only by maximum tuple length

doc/src/sgml/advanced.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ SELECT c.name, c.altitude
126126
CREATE TABLE SAL_EMP (
127127
name text,
128128
pay_by_quarter int4[],
129-
schedule char16[][]
129+
schedule text[][]
130130
);
131131
</ProgramListing>
132132
</Para>
@@ -135,7 +135,7 @@ CREATE TABLE SAL_EMP (
135135
The above query will create a class named SAL_EMP with
136136
a <FirstTerm>text</FirstTerm> string (name), a one-dimensional array of <FirstTerm>int4</FirstTerm>
137137
(pay_by_quarter), which represents the employee's
138-
salary by quarter and a two-dimensional array of <FirstTerm>char16</FirstTerm>
138+
salary by quarter and a two-dimensional array of <FirstTerm>text</FirstTerm>
139139
(schedule), which represents the employee's weekly
140140
schedule. Now we do some <FirstTerm>INSERTS</FirstTerm>s; note that when
141141
appending to an array, we enclose the values within

doc/src/sgml/array.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This must become a chapter on array behavior. Volunteers? - thomas 1998-01-12
2020
CREATE TABLE SAL_EMP (
2121
name text,
2222
pay_by_quarter int4[],
23-
schedule char16[][]
23+
schedule text[][]
2424
);
2525
</ProgramListing>
2626
</Para>
@@ -29,7 +29,7 @@ CREATE TABLE SAL_EMP (
2929
The above query will create a class named SAL_EMP with
3030
a <FirstTerm>text</FirstTerm> string (name), a one-dimensional array of <FirstTerm>int4</FirstTerm>
3131
(pay_by_quarter), which represents the employee's
32-
salary by quarter and a two-dimensional array of <FirstTerm>char16</FirstTerm>
32+
salary by quarter and a two-dimensional array of <FirstTerm>text</FirstTerm>
3333
(schedule), which represents the employee's weekly
3434
schedule. Now we do some <FirstTerm>INSERTS</FirstTerm>s; note that when
3535
appending to an array, we enclose the values within

doc/src/sgml/datatype.sgml

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,16 @@ limit to be declared on the size of the field.
368368
</Para>
369369

370370
<Para>
371-
There are currently other fixed-length character types. These provide no additional
372-
functionality and are likely to be deprecated in the future.
371+
There is currently one other fixed-length character type. The <Type>name</Type> type
372+
only has one purpose and that is to provide <ProductName>Postgres</ProductName> with a
373+
special type to use for internal names. It is not intended for use by the general user.
374+
It's length is currently defined as 32 chars but should be reference using NAMEDATALEN.
375+
This is set at compile time and may change in any future release.
373376
</Para>
374377

375378
<Para>
376379
<TABLE TOCENTRY="1">
377-
<TITLE><ProductName>Postgres</ProductName> Specialty Character Types</TITLE>
380+
<TITLE><ProductName>Postgres</ProductName> Specialty Character Type</TITLE>
378381
<TITLEABBREV>Specialty Characters</TITLEABBREV>
379382
<TGROUP COLS="3">
380383
<THEAD>
@@ -386,24 +389,9 @@ functionality and are likely to be deprecated in the future.
386389
</THEAD>
387390
<TBODY>
388391
<ROW>
389-
<ENTRY>char2</ENTRY>
390-
<ENTRY>2 bytes</ENTRY>
391-
<ENTRY>Two characters</ENTRY>
392-
</ROW>
393-
<ROW>
394-
<ENTRY>char4</ENTRY>
395-
<ENTRY>4 bytes</ENTRY>
396-
<ENTRY>Four characters</ENTRY>
397-
</ROW>
398-
<ROW>
399-
<ENTRY>char8</ENTRY>
400-
<ENTRY>8 bytes</ENTRY>
401-
<ENTRY>Eight characters</ENTRY>
402-
</ROW>
403-
<ROW>
404-
<ENTRY>char16</ENTRY>
405-
<ENTRY>16 bytes</ENTRY>
406-
<ENTRY>Sixteen characters</ENTRY>
392+
<ENTRY>name</ENTRY>
393+
<ENTRY>32 bytes</ENTRY>
394+
<ENTRY>Thirty-two character internal type</ENTRY>
407395
</ROW>
408396
</TBODY>
409397
</TGROUP>

doc/src/sgml/libpq.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ void PQputline(PGconn *conn,
736736
int PQendcopy(PGconn *conn);
737737
</ProgramListing>
738738
<ProgramListing>
739-
PQexec(conn, "create table foo (a int4, b char16, d float8)");
739+
PQexec(conn, "create table foo (a int4, b text, d float8)");
740740
PQexec(conn, "copy foo from stdin");
741741
PQputline(conn, "3&lt;TAB&gt;hello world&lt;TAB&gt;4.5\n");
742742
PQputline(conn,"4&lt;TAB&gt;goodbye world&lt;TAB&gt;7.11\n");

doc/src/sgml/xfunc.sgml

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
AS 'SELECT \'None\'::text AS name,
137137
1000 AS salary,
138138
25 AS age,
139-
\'none\'::char16 AS dept;'
139+
\'none\'::text AS dept;'
140140
LANGUAGE 'sql';
141141
</ProgramListing>
142142

@@ -263,7 +263,7 @@ The reason why, in general, we must use the function
263263
<Para>
264264
On the other hand, fixed-length types of any size may
265265
be passed by-reference. For example, here is a sample
266-
implementation of the <ProductName>Postgres</ProductName> char16 type:
266+
implementation of a <ProductName>Postgres</ProductName> type:
267267

268268
<ProgramListing>
269269
/* 16-byte structure, passed by reference */
@@ -305,7 +305,6 @@ The reason why, in general, we must use the function
305305
structure, we might use a code fragment like this:
306306
<ProgramListing>
307307
#include "postgres.h"
308-
#include "utils/palloc.h"
309308
...
310309
char buffer[40]; /* our source data */
311310
...
@@ -322,20 +321,23 @@ The reason why, in general, we must use the function
322321
Suppose <FileName>funcs.c</FileName> look like:
323322
<ProgramListing>
324323
#include &lt;string.h&gt;
325-
#include "postgres.h" /* for char16, etc. */
326-
#include "utils/palloc.h" /* for palloc */
324+
#include "postgres.h"
327325
int
328326
add_one(int arg)
329327
{
330328
return(arg + 1);
331329
}
332-
char16 *
333-
concat16(char16 *arg1, char16 *arg2)
330+
text *
331+
concat_text(text *arg1, text *arg2)
334332
{
335-
char16 *new_c16 = (char16 *) palloc(sizeof(char16));
336-
memset((void *) new_c16, 0, sizeof(char16));
337-
(void) strncpy(new_c16, arg1, 16);
338-
return (char16 *)(strncat(new_c16, arg2, 16));
333+
int32 new_text_size = VARSIZE(arg1) + VARSIZE(arg2) - VARHDRSZ;
334+
text *new_text = (text *) palloc(new_text_size);
335+
336+
memset((void *) new_text, 0, new_text_size);
337+
VARSIZE(new_text) = new_text_size;
338+
strncpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)-VARHDRSZ);
339+
strncat(VARDATA(new_text), VARDATA(arg2), VARSIZE(arg2)-VARHDRSZ);
340+
return (new_text);
339341
}
340342
text *
341343
copytext(text *t)
@@ -364,7 +366,7 @@ The reason why, in general, we must use the function
364366
CREATE FUNCTION add_one(int4) RETURNS int4
365367
AS 'PGROOT/tutorial/obj/funcs.so' LANGUAGE 'c';
366368

367-
CREATE FUNCTION concat16(char16, char16) RETURNS char16
369+
CREATE FUNCTION concat_text(text, text) RETURNS text
368370
AS 'PGROOT/tutorial/obj/funcs.so' LANGUAGE 'c';
369371

370372
CREATE FUNCTION copytext(text) RETURNS text
@@ -401,7 +403,7 @@ The reason why, in general, we must use the function
401403
In the query above, we can define c_overpaid as:
402404

403405
<ProgramListing>
404-
#include "postgres.h" /* for char16, etc. */
406+
#include "postgres.h"
405407
#include "libpq-fe.h" /* for TUPLE */
406408
bool
407409
c_overpaid(TUPLE t,/* the current instance of EMP */
@@ -426,7 +428,7 @@ The reason why, in general, we must use the function
426428
is null. <Acronym>GetAttributeByName</Acronym> will align data properly
427429
so you can cast its return value to the desired type.
428430
For example, if you have an attribute name which is of
429-
the type char16, the <Acronym>GetAttributeByName</Acronym> call would look
431+
the type name, the <Acronym>GetAttributeByName</Acronym> call would look
430432
like:
431433
<ProgramListing>
432434
char *str;
@@ -517,8 +519,9 @@ Most of the header (include) files for <ProductName>Postgres</ProductName>
517519
</Para>
518520
<ListItem>
519521
<Para> Most of the internal <ProductName>Postgres</ProductName> types are declared
520-
in postgres.h, so it's usually a good idea to
521-
include that file as well.
522+
in postgres.h, so it's a good idea to always
523+
include that file as well. Including postgres.h
524+
will also include elog.h and palloc.h for you.
522525
</Para>
523526
<ListItem>
524527
<Para> Compiling and loading your object code so that

0 commit comments

Comments
 (0)