Skip to content

Commit 0f085f6

Browse files
committed
Add proallargtypes and proargmodes columns to pg_proc, as per my earlier
proposal for OUT parameter support. The columns don't actually *do* anything yet, they are just left NULLs. But I thought I'd commit this part separately as a fairly pure example of the tasks needed when adding a column to pg_proc or one of the other core system tables.
1 parent eb47ee4 commit 0f085f6

File tree

8 files changed

+1774
-1716
lines changed

8 files changed

+1774
-1716
lines changed

doc/src/sgml/bki.sgml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.13 2005/01/05 23:42:03 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.14 2005/03/29 19:44:22 tgl Exp $
33
-->
44

55
<chapter id="bki">
@@ -97,6 +97,7 @@ $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.13 2005/01/05 23:42:03 tgl Exp $
9797
<type>oid</type>, <type>tid</type>, <type>xid</type>,
9898
<type>cid</type>, <type>int2vector</type>, <type>oidvector</type>,
9999
<type>_int4</type> (array), <type>_text</type> (array),
100+
<type>_oid</type> (array), <type>_char</type> (array),
100101
<type>_aclitem</type> (array). Although it is possible to create
101102
tables containing columns of other types, this cannot be done until
102103
after <structname>pg_type</> has been created and filled with

doc/src/sgml/catalogs.sgml

+37-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
Documentation of the system catalogs, directed toward PostgreSQL developers
3-
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.98 2005/03/29 00:16:49 tgl Exp $
3+
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.99 2005/03/29 19:44:22 tgl Exp $
44
-->
55

66
<chapter id="catalogs">
@@ -2855,7 +2855,39 @@
28552855
<entry><structfield>proargtypes</structfield></entry>
28562856
<entry><type>oidvector</type></entry>
28572857
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
2858-
<entry>An array with the data types of the function arguments</entry>
2858+
<entry>
2859+
An array with the data types of the function arguments. This includes
2860+
only input arguments (including INOUT arguments), and thus represents
2861+
the call signature of the function.
2862+
</entry>
2863+
</row>
2864+
2865+
<row>
2866+
<entry><structfield>proallargtypes</structfield></entry>
2867+
<entry><type>oid[]</type></entry>
2868+
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
2869+
<entry>
2870+
An array with the data types of the function arguments. This includes
2871+
all arguments (including OUT and INOUT arguments); however, if all the
2872+
arguments are IN arguments, this field will be null.
2873+
Note that subscripting is 1-based, whereas for historical reasons
2874+
<structfield>proargtypes</> is subscripted from 0.
2875+
</entry>
2876+
</row>
2877+
2878+
<row>
2879+
<entry><structfield>proargmodes</structfield></entry>
2880+
<entry><type>"char"[]</type></entry>
2881+
<entry></entry>
2882+
<entry>
2883+
An array with the modes of the function arguments, encoded as
2884+
<literal>i</literal> for IN arguments,
2885+
<literal>o</literal> for OUT arguments,
2886+
<literal>b</literal> for INOUT arguments.
2887+
If all the arguments are IN arguments, this field will be null.
2888+
Note that subscripts correspond to positions of
2889+
<structfield>proallargtypes</> not <structfield>proargtypes</>.
2890+
</entry>
28592891
</row>
28602892

28612893
<row>
@@ -2865,7 +2897,9 @@
28652897
<entry>
28662898
An array with the names of the function arguments.
28672899
Arguments without a name are set to empty strings in the array.
2868-
If none of the arguments have a name, this field may be null.
2900+
If none of the arguments have a name, this field will be null.
2901+
Note that subscripts correspond to positions of
2902+
<structfield>proallargtypes</> not <structfield>proargtypes</>.
28692903
</entry>
28702904
</row>
28712905

src/backend/bootstrap/bootstrap.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.200 2005/03/29 00:16:54 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.201 2005/03/29 19:44:22 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -147,6 +147,10 @@ static const struct typinfo TypInfo[] = {
147147
F_ARRAY_IN, F_ARRAY_OUT},
148148
{"_text", 1009, TEXTOID, -1, false, 'i', 'x',
149149
F_ARRAY_IN, F_ARRAY_OUT},
150+
{"_oid", 1028, OIDOID, -1, false, 'i', 'x',
151+
F_ARRAY_IN, F_ARRAY_OUT},
152+
{"_char", 1002, CHAROID, -1, false, 'i', 'x',
153+
F_ARRAY_IN, F_ARRAY_OUT},
150154
{"_aclitem", 1034, ACLITEMOID, -1, false, 'i', 'x',
151155
F_ARRAY_IN, F_ARRAY_OUT}
152156
};

src/backend/catalog/pg_proc.c

+24-24
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.124 2005/03/29 00:16:56 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/pg_proc.c,v 1.125 2005/03/29 19:44:23 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -151,32 +151,36 @@ ProcedureCreate(const char *procedureName,
151151
for (i = 0; i < Natts_pg_proc; ++i)
152152
{
153153
nulls[i] = ' ';
154-
values[i] = (Datum) NULL;
154+
values[i] = (Datum) 0;
155155
replaces[i] = 'r';
156156
}
157157

158-
i = 0;
159158
namestrcpy(&procname, procedureName);
160-
values[i++] = NameGetDatum(&procname); /* proname */
161-
values[i++] = ObjectIdGetDatum(procNamespace); /* pronamespace */
162-
values[i++] = Int32GetDatum(GetUserId()); /* proowner */
163-
values[i++] = ObjectIdGetDatum(languageObjectId); /* prolang */
164-
values[i++] = BoolGetDatum(isAgg); /* proisagg */
165-
values[i++] = BoolGetDatum(security_definer); /* prosecdef */
166-
values[i++] = BoolGetDatum(isStrict); /* proisstrict */
167-
values[i++] = BoolGetDatum(returnsSet); /* proretset */
168-
values[i++] = CharGetDatum(volatility); /* provolatile */
169-
values[i++] = UInt16GetDatum(parameterCount); /* pronargs */
170-
values[i++] = ObjectIdGetDatum(returnType); /* prorettype */
171-
values[i++] = PointerGetDatum(proargtypes); /* proargtypes */
172-
values[i++] = namesarray; /* proargnames */
173-
if (namesarray == PointerGetDatum(NULL))
159+
values[Anum_pg_proc_proname - 1] = NameGetDatum(&procname);
160+
values[Anum_pg_proc_pronamespace - 1] = ObjectIdGetDatum(procNamespace);
161+
values[Anum_pg_proc_proowner - 1] = Int32GetDatum(GetUserId());
162+
values[Anum_pg_proc_prolang - 1] = ObjectIdGetDatum(languageObjectId);
163+
values[Anum_pg_proc_proisagg - 1] = BoolGetDatum(isAgg);
164+
values[Anum_pg_proc_prosecdef - 1] = BoolGetDatum(security_definer);
165+
values[Anum_pg_proc_proisstrict - 1] = BoolGetDatum(isStrict);
166+
values[Anum_pg_proc_proretset - 1] = BoolGetDatum(returnsSet);
167+
values[Anum_pg_proc_provolatile - 1] = CharGetDatum(volatility);
168+
values[Anum_pg_proc_pronargs - 1] = UInt16GetDatum(parameterCount);
169+
values[Anum_pg_proc_prorettype - 1] = ObjectIdGetDatum(returnType);
170+
values[Anum_pg_proc_proargtypes - 1] = PointerGetDatum(proargtypes);
171+
/* XXX for now, just null out the new columns */
172+
nulls[Anum_pg_proc_proallargtypes - 1] = 'n';
173+
nulls[Anum_pg_proc_proargmodes - 1] = 'n';
174+
if (namesarray != PointerGetDatum(NULL))
175+
values[Anum_pg_proc_proargnames - 1] = namesarray;
176+
else
174177
nulls[Anum_pg_proc_proargnames - 1] = 'n';
175-
values[i++] = DirectFunctionCall1(textin, /* prosrc */
178+
values[Anum_pg_proc_prosrc - 1] = DirectFunctionCall1(textin,
176179
CStringGetDatum(prosrc));
177-
values[i++] = DirectFunctionCall1(textin, /* probin */
180+
values[Anum_pg_proc_probin - 1] = DirectFunctionCall1(textin,
178181
CStringGetDatum(probin));
179-
/* proacl will be handled below */
182+
/* start out with empty permissions */
183+
nulls[Anum_pg_proc_proacl - 1] = 'n';
180184

181185
rel = heap_openr(ProcedureRelationName, RowExclusiveLock);
182186
tupDesc = RelationGetDescr(rel);
@@ -242,10 +246,6 @@ ProcedureCreate(const char *procedureName,
242246
else
243247
{
244248
/* Creating a new procedure */
245-
246-
/* start out with empty permissions */
247-
nulls[Anum_pg_proc_proacl - 1] = 'n';
248-
249249
tup = heap_formtuple(tupDesc, values, nulls);
250250
simple_heap_insert(rel, tup);
251251
is_update = false;

src/include/catalog/catversion.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.261 2005/03/29 00:17:16 tgl Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.262 2005/03/29 19:44:23 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 200503281
56+
#define CATALOG_VERSION_NO 200503291
5757

5858
#endif

src/include/catalog/pg_attribute.h

+13-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.114 2005/03/29 00:17:17 tgl Exp $
11+
* $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.115 2005/03/29 19:44:23 tgl Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -318,10 +318,12 @@ DATA(insert ( 1262 tableoid 26 0 4 -7 0 -1 -1 t p i t f f t 0));
318318
{ 1255, {"pronargs"}, 21, -1, 2, 10, 0, -1, -1, true, 'p', 's', true, false, false, true, 0 }, \
319319
{ 1255, {"prorettype"}, 26, -1, 4, 11, 0, -1, -1, true, 'p', 'i', true, false, false, true, 0 }, \
320320
{ 1255, {"proargtypes"}, 30, -1, -1, 12, 1, -1, -1, false, 'p', 'i', true, false, false, true, 0 }, \
321-
{ 1255, {"proargnames"}, 1009, -1, -1, 13, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \
322-
{ 1255, {"prosrc"}, 25, -1, -1, 14, 0, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \
323-
{ 1255, {"probin"}, 17, -1, -1, 15, 0, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \
324-
{ 1255, {"proacl"}, 1034, -1, -1, 16, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }
321+
{ 1255, {"proallargtypes"}, 1028, -1, -1, 13, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \
322+
{ 1255, {"proargmodes"}, 1002, -1, -1, 14, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \
323+
{ 1255, {"proargnames"}, 1009, -1, -1, 15, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \
324+
{ 1255, {"prosrc"}, 25, -1, -1, 16, 0, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \
325+
{ 1255, {"probin"}, 17, -1, -1, 17, 0, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \
326+
{ 1255, {"proacl"}, 1034, -1, -1, 18, 1, -1, -1, false, 'x', 'i', false, false, false, true, 0 }
325327

326328
DATA(insert ( 1255 proname 19 -1 NAMEDATALEN 1 0 -1 -1 f p i t f f t 0));
327329
DATA(insert ( 1255 pronamespace 26 -1 4 2 0 -1 -1 t p i t f f t 0));
@@ -335,10 +337,12 @@ DATA(insert ( 1255 provolatile 18 -1 1 9 0 -1 -1 t p c t f f t 0));
335337
DATA(insert ( 1255 pronargs 21 -1 2 10 0 -1 -1 t p s t f f t 0));
336338
DATA(insert ( 1255 prorettype 26 -1 4 11 0 -1 -1 t p i t f f t 0));
337339
DATA(insert ( 1255 proargtypes 30 -1 -1 12 1 -1 -1 f p i t f f t 0));
338-
DATA(insert ( 1255 proargnames 1009 -1 -1 13 1 -1 -1 f x i f f f t 0));
339-
DATA(insert ( 1255 prosrc 25 -1 -1 14 0 -1 -1 f x i f f f t 0));
340-
DATA(insert ( 1255 probin 17 -1 -1 15 0 -1 -1 f x i f f f t 0));
341-
DATA(insert ( 1255 proacl 1034 -1 -1 16 1 -1 -1 f x i f f f t 0));
340+
DATA(insert ( 1255 proallargtypes 1028 -1 -1 13 1 -1 -1 f x i f f f t 0));
341+
DATA(insert ( 1255 proargmodes 1002 -1 -1 14 1 -1 -1 f x i f f f t 0));
342+
DATA(insert ( 1255 proargnames 1009 -1 -1 15 1 -1 -1 f x i f f f t 0));
343+
DATA(insert ( 1255 prosrc 25 -1 -1 16 0 -1 -1 f x i f f f t 0));
344+
DATA(insert ( 1255 probin 17 -1 -1 17 0 -1 -1 f x i f f f t 0));
345+
DATA(insert ( 1255 proacl 1034 -1 -1 18 1 -1 -1 f x i f f f t 0));
342346
DATA(insert ( 1255 ctid 27 0 6 -1 0 -1 -1 f p s t f f t 0));
343347
DATA(insert ( 1255 oid 26 0 4 -2 0 -1 -1 t p i t f f t 0));
344348
DATA(insert ( 1255 xmin 28 0 4 -3 0 -1 -1 t p i t f f t 0));

src/include/catalog/pg_class.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.85 2004/12/31 22:03:24 pgsql Exp $
11+
* $PostgreSQL: pgsql/src/include/catalog/pg_class.h,v 1.86 2005/03/29 19:44:23 tgl Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -140,7 +140,7 @@ DATA(insert OID = 1247 ( pg_type PGNSP 71 PGUID 0 1247 0 0 0 0 0 f f r 23 0 0
140140
DESCR("");
141141
DATA(insert OID = 1249 ( pg_attribute PGNSP 75 PGUID 0 1249 0 0 0 0 0 f f r 17 0 0 0 0 0 f f f f _null_ ));
142142
DESCR("");
143-
DATA(insert OID = 1255 ( pg_proc PGNSP 81 PGUID 0 1255 0 0 0 0 0 f f r 16 0 0 0 0 0 t f f f _null_ ));
143+
DATA(insert OID = 1255 ( pg_proc PGNSP 81 PGUID 0 1255 0 0 0 0 0 f f r 18 0 0 0 0 0 t f f f _null_ ));
144144
DESCR("");
145145
DATA(insert OID = 1259 ( pg_class PGNSP 83 PGUID 0 1259 0 0 0 0 0 f f r 25 0 0 0 0 0 t f f f _null_ ));
146146
DESCR("");

0 commit comments

Comments
 (0)