Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0213835

Browse files
committed
Remove "convert 'blah' using conversion_name" facility, because if it
produces text it is an encoding hole and if not it's incompatiblewith the spec, whatever the spec means (which we're not sure about anyway).
1 parentc3b193a commit0213835

File tree

9 files changed

+15
-1046
lines changed

9 files changed

+15
-1046
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.397 2007/09/19 03:13:57 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.398 2007/09/24 01:29:27 adunstan Exp $ -->
22

33
<chapter id="functions">
44
<title>Functions and Operators</title>
@@ -1022,9 +1022,6 @@
10221022
<indexterm>
10231023
<primary>char_length</primary>
10241024
</indexterm>
1025-
<indexterm>
1026-
<primary>convert</primary>
1027-
</indexterm>
10281025
<indexterm>
10291026
<primary>lower</primary>
10301027
</indexterm>
@@ -1119,22 +1116,6 @@
11191116
<entry><literal>4</literal></entry>
11201117
</row>
11211118

1122-
<row>
1123-
<entry><literal><function>convert</function>(<parameter>string</parameter>
1124-
using <parameter>conversion_name</parameter>)</literal></entry>
1125-
<entry><type>bytea</type></entry>
1126-
<entry>
1127-
Change encoding using specified conversion name. Conversions
1128-
can be defined by <command>CREATE CONVERSION</command>. Also
1129-
there are some pre-defined conversion names. See <xref
1130-
linkend="conversion-names"> for available conversion
1131-
names. The <parameter>string</parameter> must be valid in the
1132-
source encoding.
1133-
</entry>
1134-
<entry><literal>convert('PostgreSQL' using iso_8859_1_to_utf8)</literal></entry>
1135-
<entry><literal>'PostgreSQL'</literal> in UTF8 (Unicode, 8-bit) encoding</entry>
1136-
</row>
1137-
11381119
<row>
11391120
<entry><literal><function>lower</function>(<parameter>string</parameter>)</literal></entry>
11401121
<entry><type>text</type></entry>
@@ -1245,6 +1226,9 @@
12451226
<indexterm>
12461227
<primary>chr</primary>
12471228
</indexterm>
1229+
<indexterm>
1230+
<primary>convert</primary>
1231+
</indexterm>
12481232
<indexterm>
12491233
<primary>convert_from</primary>
12501234
</indexterm>
@@ -1374,6 +1358,9 @@
13741358
original encoding is specified by
13751359
<parameter>src_encoding</parameter>. The
13761360
<parameter>string</parameter> must be valid in this encoding.
1361+
Conversions can be defined by <command>CREATE CONVERSION</command>.
1362+
Also there are some pre-defined conversions. See <xref
1363+
linkend="conversion-names"> for available conversions.
13771364
</entry>
13781365
<entry><literal>convert( 'text_in_utf8', 'UTF8', 'LATIN1')</literal></entry>
13791366
<entry><literal>text_in_utf8</literal> represented in ISO 8859-1 encoding</entry>

‎doc/src/sgml/ref/create_conversion.sgml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/create_conversion.sgml,v 1.19 2007/01/31 23:26:03 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/create_conversion.sgml,v 1.20 2007/09/24 01:29:28 adunstan Exp $ -->
22

33
<refentry id="SQL-CREATECONVERSION">
44
<refmeta>
@@ -27,9 +27,7 @@ CREATE [ DEFAULT ] CONVERSION <replaceable>name</replaceable>
2727

2828
<para>
2929
<command>CREATE CONVERSION</command> defines a new conversion between
30-
character set encodings. Conversion names can be used in the
31-
<function>convert</function> function
32-
to specify a particular encoding conversion. Also, conversions that
30+
character set encodings. Also, conversions that
3331
are marked <literal>DEFAULT</> can be used for automatic encoding
3432
conversion between
3533
client and server. For this purpose, two conversions, from encoding A to

‎src/backend/catalog/pg_conversion.c

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/pg_conversion.c,v 1.37 2007/09/18 17:41:17 adunstan Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/pg_conversion.c,v 1.38 2007/09/24 01:29:28 adunstan Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -276,76 +276,3 @@ FindConversion(const char *conname, Oid connamespace)
276276
returnconoid;
277277
}
278278

279-
/*
280-
* Execute SQL99's CONVERT function.
281-
*
282-
* CONVERT <left paren> <character value expression>
283-
* USING <form-of-use conversion name> <right paren>
284-
*
285-
* BYTEA convert_using(TEXT string, TEXT conversion_name)
286-
*
287-
* bytea is returned so we don't give a value that is
288-
* not valid in the database encoding.
289-
*/
290-
Datum
291-
pg_convert_using(PG_FUNCTION_ARGS)
292-
{
293-
text*string=PG_GETARG_TEXT_P(0);
294-
text*conv_name=PG_GETARG_TEXT_P(1);
295-
text*retval;
296-
List*parsed_name;
297-
Oidconvoid;
298-
HeapTupletuple;
299-
Form_pg_conversionbody;
300-
char*str;
301-
char*result;
302-
intlen;
303-
304-
/* Convert input string to null-terminated form */
305-
len=VARSIZE(string)-VARHDRSZ;
306-
str=palloc(len+1);
307-
memcpy(str,VARDATA(string),len);
308-
*(str+len)='\0';
309-
310-
/* Look up the conversion name */
311-
parsed_name=textToQualifiedNameList(conv_name);
312-
convoid=FindConversionByName(parsed_name);
313-
if (!OidIsValid(convoid))
314-
ereport(ERROR,
315-
(errcode(ERRCODE_UNDEFINED_OBJECT),
316-
errmsg("conversion \"%s\" does not exist",
317-
NameListToString(parsed_name))));
318-
319-
tuple=SearchSysCache(CONVOID,
320-
ObjectIdGetDatum(convoid),
321-
0,0,0);
322-
if (!HeapTupleIsValid(tuple))
323-
elog(ERROR,"cache lookup failed for conversion %u",convoid);
324-
body= (Form_pg_conversion)GETSTRUCT(tuple);
325-
326-
/* Temporary result area should be more than big enough */
327-
result=palloc(len*4+1);
328-
329-
OidFunctionCall5(body->conproc,
330-
Int32GetDatum(body->conforencoding),
331-
Int32GetDatum(body->contoencoding),
332-
CStringGetDatum(str),
333-
CStringGetDatum(result),
334-
Int32GetDatum(len));
335-
336-
ReleaseSysCache(tuple);
337-
338-
/*
339-
* build text result structure. we cannot use textin() here, since textin
340-
* assumes that input string encoding is same as database encoding.
341-
*/
342-
len=strlen(result)+VARHDRSZ;
343-
retval=palloc(len);
344-
SET_VARSIZE(retval,len);
345-
memcpy(VARDATA(retval),result,len-VARHDRSZ);
346-
347-
pfree(result);
348-
pfree(str);
349-
350-
PG_RETURN_BYTEA_P(retval);
351-
}

‎src/backend/parser/gram.y

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.602 2007/09/03 18:46:30 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.603 2007/09/24 01:29:28 adunstan Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -377,7 +377,7 @@ static Node *makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args)
377377
CHARACTER CHARACTERISTICS CHECK CHECKPOINT CLASS CLOSE
378378
CLUSTER COALESCE COLLATE COLUMN COMMENT COMMIT
379379
COMMITTED CONCURRENTLY CONFIGURATION CONNECTION CONSTRAINT CONSTRAINTS
380-
CONTENT_P CONVERSION_PCONVERTCOPY COST CREATE CREATEDB
380+
CONTENT_P CONVERSION_P COPY COST CREATE CREATEDB
381381
CREATEROLE CREATEUSER CROSS CSV CURRENT_P CURRENT_DATE CURRENT_ROLE
382382
CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER CURSOR CYCLE
383383

@@ -8218,31 +8218,6 @@ func_expr:func_name '(' ')'
82188218
n->location =@1;
82198219
$$ = (Node *)n;
82208220
}
8221-
| CONVERT'(' a_expr USING any_name')'
8222-
{
8223-
FuncCall *n = makeNode(FuncCall);
8224-
A_Const *c = makeNode(A_Const);
8225-
8226-
c->val.type = T_String;
8227-
c->val.val.str = NameListToQuotedString($5);
8228-
8229-
n->funcname = SystemFuncName("convert_using");
8230-
n->args = list_make2($3, c);
8231-
n->agg_star =FALSE;
8232-
n->agg_distinct =FALSE;
8233-
n->location =@1;
8234-
$$ = (Node *)n;
8235-
}
8236-
| CONVERT'(' expr_list')'
8237-
{
8238-
FuncCall *n = makeNode(FuncCall);
8239-
n->funcname = SystemFuncName("convert");
8240-
n->args =$3;
8241-
n->agg_star =FALSE;
8242-
n->agg_distinct =FALSE;
8243-
n->location =@1;
8244-
$$ = (Node *)n;
8245-
}
82468221
| NULLIF'(' a_expr',' a_expr')'
82478222
{
82488223
$$ = (Node *) makeSimpleA_Expr(AEXPR_NULLIF,"=",$3,$5,@1);
@@ -9291,7 +9266,6 @@ col_name_keyword:
92919266
| CHAR_P
92929267
| CHARACTER
92939268
| COALESCE
9294-
| CONVERT
92959269
| DEC
92969270
| DECIMAL_P
92979271
| EXISTS

‎src/backend/parser/keywords.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.191 2007/08/21 15:13:42 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/parser/keywords.c,v 1.192 2007/09/24 01:29:29 adunstan Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -93,7 +93,6 @@ static const ScanKeyword ScanKeywords[] = {
9393
{"constraints",CONSTRAINTS,UNRESERVED_KEYWORD},
9494
{"content",CONTENT_P,UNRESERVED_KEYWORD},
9595
{"conversion",CONVERSION_P,UNRESERVED_KEYWORD},
96-
{"convert",CONVERT,COL_NAME_KEYWORD},
9796
{"copy",COPY,UNRESERVED_KEYWORD},
9897
{"cost",COST,UNRESERVED_KEYWORD},
9998
{"create",CREATE,RESERVED_KEYWORD},

‎src/include/catalog/pg_proc.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.471 2007/09/20 17:56:32 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.472 2007/09/24 01:29:29 adunstan Exp $
1111
*
1212
* NOTES
1313
* The script catalog/genbki.sh reads this file and generates .bki
@@ -2244,9 +2244,6 @@ DESCR("convert string with specified destination encoding name");
22442244
DATA(insertOID=1813 (convertPGNSPPGUID1210fftfs317"17 19 19"_null__null__null_pg_convert-_null__null_ ));
22452245
DESCR("convert string with specified encoding names");
22462246

2247-
DATA(insertOID=1619 (convert_usingPGNSPPGUID1210fftfs217"25 25"_null__null__null_pg_convert_using-_null__null_ ));
2248-
DESCR("convert string with specified conversion name");
2249-
22502247
DATA(insertOID=1264 (pg_char_to_encodingPGNSPPGUID1210fftfs123"19"_null__null__null_PG_char_to_encoding-_null__null_ ));
22512248
DESCR("convert encoding name to encoding id");
22522249

‎src/include/utils/builtins.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.303 2007/09/18 17:41:17 adunstan Exp $
10+
* $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.304 2007/09/24 01:29:30 adunstan Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -941,9 +941,6 @@ extern Datum pg_advisory_unlock_all(PG_FUNCTION_ARGS);
941941
/* access/transam/twophase.c */
942942
externDatumpg_prepared_xact(PG_FUNCTION_ARGS);
943943

944-
/* catalog/pg_conversion.c */
945-
externDatumpg_convert_using(PG_FUNCTION_ARGS);
946-
947944
/* commands/prepare.c */
948945
externDatumpg_prepared_statement(PG_FUNCTION_ARGS);
949946

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp