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

Commit31edbad

Browse files
committed
Downgrade implicit casts to text to be assignment-only, except for the ones
from the other string-category types; this eliminates a lot of surprisinginterpretations that the parser could formerly make when there was no directlyapplicable operator.Create a general mechanism that supports casts to and from the standard stringtypes (text,varchar,bpchar) for *every* datatype, by invoking the datatype'sI/O functions. These new casts are assignment-only in the to-string direction,explicit-only in the other, and therefore should create no surprising behavior.Remove a bunch of thereby-obsoleted datatype-specific casting functions.The "general mechanism" is a new expression node type CoerceViaIO that canactually convert between *any* two datatypes if their external textrepresentations are compatible. This is more general than needed for theimmediate feature, but might be useful in plpgsql or other places in future.This commit does nothing about the issue that applying the concatenationoperator || to non-text types will now fail, often with strange error messagesdue to misinterpreting the operator as array concatenation. Since it often(not always) worked before, we should either make it succeed or at least givea more user-friendly error; but details are still under debate.Peter Eisentraut and Tom Lane
1 parent1120b99 commit31edbad

File tree

60 files changed

+848
-1610
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+848
-1610
lines changed

‎contrib/cube/README.cube‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,6 @@ cube_distance(cube, cube) returns double
236236
cube_distance returns the distance between two cubes. If both cubes are
237237
points, this is the normal distance function.
238238

239-
cube(text) returns cube
240-
cube takes text input and returns a cube. This is useful for making cubes
241-
from computed strings.
242-
243239
cube(float8) returns cube
244240
This makes a one dimensional cube with both coordinates the same.
245241
If the type of the argument is a numeric type other than float8 an

‎contrib/cube/cube.c‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/******************************************************************************
2-
$PostgreSQL: pgsql/contrib/cube/cube.c,v 1.32 2007/03/07 21:21:11 teodor Exp $
2+
$PostgreSQL: pgsql/contrib/cube/cube.c,v 1.33 2007/06/05 21:31:03 tgl Exp $
33
44
This file contains routines that can be bound to a Postgres backend and
55
called by the backend in the process of processing queries. The calling
@@ -173,18 +173,6 @@ cube_in(PG_FUNCTION_ARGS)
173173
PG_RETURN_NDBOX(result);
174174
}
175175

176-
/* Allow conversion from text to cube to allow input of computed strings */
177-
/* There may be issues with toasted data here. I don't know enough to be sure.*/
178-
Datum
179-
cube(PG_FUNCTION_ARGS)
180-
{
181-
char*cstring;
182-
183-
cstring=DatumGetCString(DirectFunctionCall1(textout,PointerGetDatum(PG_GETARG_TEXT_P(0))));
184-
185-
PG_RETURN_DATUM(DirectFunctionCall1(cube_in,PointerGetDatum(cstring)));
186-
}
187-
188176

189177
/*
190178
** Allows the construction of a cube from 2 float[]'s

‎contrib/cube/cube.sql.in‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ CREATE TYPE cube (
3131

3232
COMMENT ON TYPE cube IS 'multi-dimensional cube ''(FLOAT-1, FLOAT-2, ..., FLOAT-N), (FLOAT-1, FLOAT-2, ..., FLOAT-N)''';
3333

34-
-- Convert from text to cube
35-
36-
CREATE OR REPLACE FUNCTION cube(text) RETURNS cube
37-
AS 'MODULE_PATHNAME'
38-
LANGUAGE C IMMUTABLE STRICT;
39-
40-
COMMENT ON FUNCTION cube(text) IS 'convert text to cube';
41-
42-
CREATE CAST (text AS cube) WITH FUNCTION cube(text) AS ASSIGNMENT;
43-
4434
--
4535
-- External C-functions for R-tree methods
4636
--

‎contrib/cube/expected/cube.out‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ SELECT cube_distance('(0)'::cube,'(.3,.4)'::cube);
826826

827827
-- Test of cube function (text to cube)
828828
--
829-
SELECT cube('('||1||','||1.2||')');
829+
SELECT cube('(1,1.2)'::text);
830830
cube
831831
----------
832832
(1, 1.2)

‎contrib/cube/expected/cube_1.out‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ SELECT cube_distance('(0)'::cube,'(.3,.4)'::cube);
826826

827827
-- Test of cube function (text to cube)
828828
--
829-
SELECT cube('('||1||','||1.2||')');
829+
SELECT cube('(1,1.2)'::text);
830830
cube
831831
----------
832832
(1, 1.2)

‎contrib/cube/expected/cube_2.out‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ SELECT cube_distance('(0)'::cube,'(.3,.4)'::cube);
826826

827827
-- Test of cube function (text to cube)
828828
--
829-
SELECT cube('('||1||','||1.2||')');
829+
SELECT cube('(1,1.2)'::text);
830830
cube
831831
----------
832832
(1, 1.2)

‎contrib/cube/sql/cube.sql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ SELECT cube_distance('(0)'::cube,'(.3,.4)'::cube);
223223

224224
-- Test of cube function (text to cube)
225225
--
226-
SELECT cube('('||1||','||1.2||')');
226+
SELECT cube('(1,1.2)'::text);
227227
SELECT cube(NULL);
228228

229229
-- Test of cube_dim function (dimensions stored in cube)

‎contrib/cube/uninstall_cube.sql‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,4 @@ DROP FUNCTION cube_ne(cube, cube);
9292

9393
DROPFUNCTION cube_eq(cube, cube);
9494

95-
DROP CAST (textAS cube);
96-
97-
DROPFUNCTION cube(text);
98-
9995
DROPTYPE cube CASCADE;

‎contrib/isn/isn.c‎

Lines changed: 1 addition & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.5 2007/01/0522:19:18 momjian Exp $
10+
* $PostgreSQL: pgsql/contrib/isn/isn.c,v 1.6 2007/06/0521:31:03 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -39,10 +39,6 @@ static const char *isn_names[] = {"EAN13/UPC/ISxN", "EAN13/UPC/ISxN", "EAN13", "
3939
staticboolg_weak= false;
4040
staticboolg_initialized= false;
4141

42-
/* Macros for converting TEXT to and from c-string */
43-
#defineGET_TEXT(cstrp) DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(cstrp)))
44-
#defineGET_STR(textp) DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp)))
45-
4642

4743
/***********************************************************************
4844
**
@@ -1042,30 +1038,6 @@ upc_in(PG_FUNCTION_ARGS)
10421038

10431039
/* casting functions
10441040
*/
1045-
PG_FUNCTION_INFO_V1(ean13_cast_to_text);
1046-
Datum
1047-
ean13_cast_to_text(PG_FUNCTION_ARGS)
1048-
{
1049-
ean13val=PG_GETARG_EAN13(0);
1050-
charbuf[MAXEAN13LEN+1];
1051-
1052-
(void)ean2string(val, false,buf, false);
1053-
1054-
PG_RETURN_TEXT_P(GET_TEXT(buf));
1055-
}
1056-
1057-
PG_FUNCTION_INFO_V1(isn_cast_to_text);
1058-
Datum
1059-
isn_cast_to_text(PG_FUNCTION_ARGS)
1060-
{
1061-
ean13val=PG_GETARG_EAN13(0);
1062-
charbuf[MAXEAN13LEN+1];
1063-
1064-
(void)ean2string(val, false,buf, true);
1065-
1066-
PG_RETURN_TEXT_P(GET_TEXT(buf));
1067-
}
1068-
10691041
PG_FUNCTION_INFO_V1(isbn_cast_from_ean13);
10701042
Datum
10711043
isbn_cast_from_ean13(PG_FUNCTION_ARGS)
@@ -1115,61 +1087,6 @@ upc_cast_from_ean13(PG_FUNCTION_ARGS)
11151087
}
11161088

11171089

1118-
PG_FUNCTION_INFO_V1(ean13_cast_from_text);
1119-
Datum
1120-
ean13_cast_from_text(PG_FUNCTION_ARGS)
1121-
{
1122-
constchar*str=GET_STR(PG_GETARG_TEXT_P(0));
1123-
ean13result;
1124-
1125-
(void)string2ean(str, false,&result,EAN13);
1126-
PG_RETURN_EAN13(result);
1127-
}
1128-
1129-
PG_FUNCTION_INFO_V1(isbn_cast_from_text);
1130-
Datum
1131-
isbn_cast_from_text(PG_FUNCTION_ARGS)
1132-
{
1133-
constchar*str=GET_STR(PG_GETARG_TEXT_P(0));
1134-
ean13result;
1135-
1136-
(void)string2ean(str, false,&result,ISBN);
1137-
PG_RETURN_EAN13(result);
1138-
}
1139-
1140-
PG_FUNCTION_INFO_V1(ismn_cast_from_text);
1141-
Datum
1142-
ismn_cast_from_text(PG_FUNCTION_ARGS)
1143-
{
1144-
constchar*str=GET_STR(PG_GETARG_TEXT_P(0));
1145-
ean13result;
1146-
1147-
(void)string2ean(str, false,&result,ISMN);
1148-
PG_RETURN_EAN13(result);
1149-
}
1150-
1151-
PG_FUNCTION_INFO_V1(issn_cast_from_text);
1152-
Datum
1153-
issn_cast_from_text(PG_FUNCTION_ARGS)
1154-
{
1155-
constchar*str=GET_STR(PG_GETARG_TEXT_P(0));
1156-
ean13result;
1157-
1158-
(void)string2ean(str, false,&result,ISSN);
1159-
PG_RETURN_EAN13(result);
1160-
}
1161-
1162-
PG_FUNCTION_INFO_V1(upc_cast_from_text);
1163-
Datum
1164-
upc_cast_from_text(PG_FUNCTION_ARGS)
1165-
{
1166-
constchar*str=GET_STR(PG_GETARG_TEXT_P(0));
1167-
ean13result;
1168-
1169-
(void)string2ean(str, false,&result,UPC);
1170-
PG_RETURN_EAN13(result);
1171-
}
1172-
11731090
/* is_valid - returns false if the "invalid-check-digit-on-input" is set
11741091
*/
11751092
PG_FUNCTION_INFO_V1(is_valid);

‎contrib/isn/isn.h‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/contrib/isn/isn.h,v 1.3 2007/01/0522:19:18 momjian Exp $
10+
* $PostgreSQL: pgsql/contrib/isn/isn.h,v 1.4 2007/06/0521:31:03 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -38,13 +38,6 @@ extern Datum ismn_in(PG_FUNCTION_ARGS);
3838
externDatumissn_in(PG_FUNCTION_ARGS);
3939
externDatumupc_in(PG_FUNCTION_ARGS);
4040

41-
externDatumean13_cast_to_text(PG_FUNCTION_ARGS);
42-
externDatumisn_cast_to_text(PG_FUNCTION_ARGS);
43-
externDatumean13_cast_from_text(PG_FUNCTION_ARGS);
44-
externDatumisbn_cast_from_text(PG_FUNCTION_ARGS);
45-
externDatumismn_cast_from_text(PG_FUNCTION_ARGS);
46-
externDatumissn_cast_from_text(PG_FUNCTION_ARGS);
47-
externDatumupc_cast_from_text(PG_FUNCTION_ARGS);
4841
externDatumisbn_cast_from_ean13(PG_FUNCTION_ARGS);
4942
externDatumismn_cast_from_ean13(PG_FUNCTION_ARGS);
5043
externDatumissn_cast_from_ean13(PG_FUNCTION_ARGS);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp