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

Commit00fbb64

Browse files
committed
Un-break CREATE TYPE. Fix some other inconsistencies in the
pg_proc entries for array I/O routines besides the one detected by theoriginal patcher. Tighten type_sanity regress test accordingly.
1 parent09c5e84 commit00fbb64

File tree

4 files changed

+32
-20
lines changed

4 files changed

+32
-20
lines changed

‎src/backend/catalog/pg_type.c

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.35 1999/02/13 23:14:59 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.36 1999/04/20 03:51:14 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -390,11 +390,6 @@ TypeCreate(char *typeName,
390390
values[i++]= (Datum) (typeType=='c' ?relationOid :InvalidOid);/* 9 */
391391
values[i++]= (Datum)elementObjectId;/* 10 */
392392

393-
/*
394-
* arguments to type input and output functions must be 0
395-
*/
396-
MemSet(argList,0,8*sizeof(Oid));
397-
398393
procs[0]=inputProcedure;
399394
procs[1]=outputProcedure;
400395
procs[2]= (receiveProcedure) ?receiveProcedure :inputProcedure;
@@ -404,6 +399,12 @@ TypeCreate(char *typeName,
404399
{
405400
procname=procs[j];
406401

402+
/*
403+
* First look for a 1-argument func with all argtypes 0.
404+
* This is valid for all four kinds of procedure.
405+
*/
406+
MemSet(argList,0,8*sizeof(Oid));
407+
407408
tup=SearchSysCacheTuple(PRONAME,
408409
PointerGetDatum(procname),
409410
Int32GetDatum(1),
@@ -412,17 +413,28 @@ TypeCreate(char *typeName,
412413

413414
if (!HeapTupleIsValid(tup))
414415
{
415-
416416
/*
417-
* it is possible for the input/output procedure to take two
418-
* arguments, where the second argument is the element type
419-
* (eg array_in/array_out)
417+
* For array types, the input procedures may take 3 args
418+
* (data value, element OID, atttypmod); the pg_proc
419+
* argtype signature is 0,0,INT4OID. The output procedures
420+
* may take 2 args (data value, element OID).
420421
*/
421422
if (OidIsValid(elementObjectId))
422423
{
424+
intnargs;
425+
if (j %2)
426+
{
427+
/* output proc */
428+
nargs=2;
429+
}else
430+
{
431+
/* input proc */
432+
nargs=3;
433+
argList[2]=INT4OID;
434+
}
423435
tup=SearchSysCacheTuple(PRONAME,
424436
PointerGetDatum(procname),
425-
Int32GetDatum(2),
437+
Int32GetDatum(nargs),
426438
PointerGetDatum(argList),
427439
0);
428440
}

‎src/include/catalog/pg_proc.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_proc.h,v 1.95 1999/04/13 17:28:35 momjian Exp $
9+
* $Id: pg_proc.h,v 1.96 1999/04/20 03:51:13 tgl Exp $
1010
*
1111
* NOTES
1212
* The script catalog/genbki.sh reads this file and generates .bki
@@ -1001,9 +1001,9 @@ DESCR("array");
10011001
DATA(insertOID=751 (array_outPGUID11ftf2f23"0 0"10000100array_out- ));
10021002
DESCR("array");
10031003

1004-
DATA(insertOID=752 (filename_inPGUID11ftf2f605"0"10000100filename_in- ));
1004+
DATA(insertOID=752 (filename_inPGUID11ftf1f605"0"10000100filename_in- ));
10051005
DESCR("(internal)");
1006-
DATA(insertOID=753 (filename_outPGUID11ftf2f19"0"10000100filename_out- ));
1006+
DATA(insertOID=753 (filename_outPGUID11ftf2f19"0 0"10000100filename_out- ));
10071007
DESCR("(internal)");
10081008

10091009
DATA(insertOID=760 (smgrinPGUID11ftf1f210"0"10000100smgrin- ));
@@ -1300,11 +1300,11 @@ DATA(insert OID = 1037 ( aclcontains PGUID 11 f t f 2 f 16 "1034 1033" 100 0
13001300
DESCR("matches regex., case-sensitive");
13011301
DATA(insertOID=1038 (setevalPGUID11ftf1f23"26"10000100seteval- ));
13021302
DESCR("");
1303-
DATA(insertOID=1044 (bpcharinPGUID11ftf3f1042"0"10000100bpcharin- ));
1303+
DATA(insertOID=1044 (bpcharinPGUID11ftf3f1042"0 0 23"10000100bpcharin- ));
13041304
DESCR("(internal)");
13051305
DATA(insertOID=1045 (bpcharoutPGUID11ftf1f23"0"10000100bpcharout- ));
13061306
DESCR("(internal)");
1307-
DATA(insertOID=1046 (varcharinPGUID11ftf3f1043"0"10000100varcharin- ));
1307+
DATA(insertOID=1046 (varcharinPGUID11ftf3f1043"0 0 23"10000100varcharin- ));
13081308
DESCR("(internal)");
13091309
DATA(insertOID=1047 (varcharoutPGUID11ftf1f23"0"10000100varcharout- ));
13101310
DESCR("(internal)");

‎src/test/regress/expected/type_sanity.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ QUERY: SELECT p1.oid, p1.typname, p2.oid, p2.proname
4040
FROM pg_type AS p1, pg_proc AS p2
4141
WHERE p1.typinput = p2.oid AND p1.typtype = 'b' AND
4242
(p2.pronargs != 1 OR p2.proretset) AND
43-
(p2.pronargs< 2 OR p2.pronargs > 3 OR p2.proretset OR p1.typelem = 0);
43+
(p2.pronargs!= 3 OR p2.proretset OR p1.typelem = 0);
4444
oid|typname|oid|proname
4545
---+-------+---+-------
4646
(0 rows)
@@ -58,7 +58,7 @@ QUERY: SELECT p1.oid, p1.typname, p2.oid, p2.proname
5858
FROM pg_type AS p1, pg_proc AS p2
5959
WHERE p1.typreceive = p2.oid AND p1.typtype = 'b' AND
6060
(p2.pronargs != 1 OR p2.proretset) AND
61-
(p2.pronargs< 2 OR p2.pronargs > 3 OR p2.proretset OR p1.typelem = 0);
61+
(p2.pronargs!= 3 OR p2.proretset OR p1.typelem = 0);
6262
oid|typname|oid|proname
6363
---+-------+---+-------
6464
(0 rows)

‎src/test/regress/sql/type_sanity.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ SELECT p1.oid, p1.typname, p2.oid, p2.proname
5959
FROM pg_typeAS p1, pg_procAS p2
6060
WHEREp1.typinput=p2.oidANDp1.typtype='b'AND
6161
(p2.pronargs!=1ORp2.proretset)AND
62-
(p2.pronargs<2ORp2.pronargs>3ORp2.proretsetORp1.typelem=0);
62+
(p2.pronargs!=3ORp2.proretsetORp1.typelem=0);
6363

6464
-- Check for bogus typoutput routines
6565
-- The first OR subclause detects bogus non-array cases,
@@ -83,7 +83,7 @@ SELECT p1.oid, p1.typname, p2.oid, p2.proname
8383
FROM pg_typeAS p1, pg_procAS p2
8484
WHEREp1.typreceive=p2.oidANDp1.typtype='b'AND
8585
(p2.pronargs!=1ORp2.proretset)AND
86-
(p2.pronargs<2ORp2.pronargs>3ORp2.proretsetORp1.typelem=0);
86+
(p2.pronargs!=3ORp2.proretsetORp1.typelem=0);
8787

8888
-- Check for bogus typsend routines
8989
-- The first OR subclause detects bogus non-array cases,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp