Skip to content

Commit 5bb2300

Browse files
committed
Revise handling of oldstyle/newstyle functions per recent discussions
in pghackers list. Support for oldstyle internal functions is gone (no longer needed, since conversion is complete) and pg_language entry 'internal' now implies newstyle call convention. pg_language entry 'newC' is gone; both old and newstyle dynamically loaded C functions are now called language 'C'. A newstyle function must be identified by an associated info routine. See src/backend/utils/fmgr/README.
1 parent 99198ac commit 5bb2300

Some content is hidden

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

52 files changed

+570
-327
lines changed

contrib/fulltextindex/README.fti

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ sub-string will fit.
5757
The create the function that contains the trigger::
5858

5959
create function fti() returns opaque as
60-
'/path/to/fti.so' language 'newC';
60+
'/path/to/fti.so' language 'C';
6161

6262
And finally define the trigger on the 'cds' table:
6363

contrib/fulltextindex/fti.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Example:
1818
1919
create function fti() returns opaque as
20-
'/home/boekhold/src/postgresql-6.2/contrib/fti/fti.so' language 'newC';
20+
'/home/boekhold/src/postgresql-6.2/contrib/fti/fti.so' language 'C';
2121
2222
create table title_fti (string varchar(25), id oid);
2323
create index title_fti_idx on title_fti (string);
@@ -93,6 +93,8 @@ static int nDeletePlans = 0;
9393
static EPlan *find_plan(char *ident, EPlan ** eplan, int *nplans);
9494

9595
/***********************************************************************/
96+
PG_FUNCTION_INFO_V1(fti);
97+
9698
Datum
9799
fti(PG_FUNCTION_ARGS)
98100
{

contrib/fulltextindex/fti.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#
3030
# create function fti() returns opaque as
3131
# '/path/to/fti/file/fti.so'
32-
# language 'newC';
32+
# language 'C';
3333
#
3434
# create trigger my_fti_trigger after update or insert or delete
3535
# on mytable

contrib/fulltextindex/fti.sql.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
create function fti() returns opaque as
22
'MODULE_PATHNAME'
3-
language 'newC';
3+
language 'C';

contrib/lo/lo.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* PostgreSQL type definitions for managed LargeObjects.
33
*
4-
* $Id: lo.c,v 1.4 2000/06/09 01:10:58 tgl Exp $
4+
* $Id: lo.c,v 1.5 2000/11/20 20:36:55 tgl Exp $
55
*
66
*/
77

@@ -140,6 +140,8 @@ lo(Oid oid)
140140
/*
141141
* This handles the trigger that protects us from orphaned large objects
142142
*/
143+
PG_FUNCTION_INFO_V1(lo_manage);
144+
143145
Datum
144146
lo_manage(PG_FUNCTION_ARGS)
145147
{

contrib/lo/lo.sql.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
--
22
-- PostgreSQL code for LargeObjects
33
--
4-
-- $Id: lo.sql.in,v 1.4 2000/06/19 13:53:42 momjian Exp $
4+
-- $Id: lo.sql.in,v 1.5 2000/11/20 20:36:55 tgl Exp $
55
--
66
--
77
-- Create the data type
@@ -44,7 +44,7 @@ create function lo(oid)
4444
create function lo_manage()
4545
returns opaque
4646
as 'MODULE_PATHNAME'
47-
language 'newC';
47+
language 'C';
4848

4949
-- This allows us to map lo to oid
5050
--

contrib/noupdate/noup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ extern Datum noup(PG_FUNCTION_ARGS);
1616
* EXECUTE PROCEDURE noup ('col').
1717
*/
1818

19+
PG_FUNCTION_INFO_V1(noup);
20+
1921
Datum
2022
noup(PG_FUNCTION_ARGS)
2123
{

contrib/noupdate/noup.sql.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ DROP FUNCTION noup ();
33
CREATE FUNCTION noup ()
44
RETURNS opaque
55
AS 'MODULE_PATHNAME'
6-
LANGUAGE 'newC'
7-
;
6+
LANGUAGE 'C';

contrib/pgcrypto/pgcrypto.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2727
* SUCH DAMAGE.
2828
*
29-
* $Id: pgcrypto.c,v 1.1 2000/10/31 13:11:28 petere Exp $
29+
* $Id: pgcrypto.c,v 1.2 2000/11/20 20:36:56 tgl Exp $
3030
*/
3131

3232
#include <postgres.h>
@@ -59,6 +59,8 @@ find_digest(pg_digest *hbuf, text *name, int silent);
5959

6060

6161
/* SQL function: hash(text, text) returns text */
62+
PG_FUNCTION_INFO_V1(digest);
63+
6264
Datum
6365
digest(PG_FUNCTION_ARGS)
6466
{
@@ -95,6 +97,8 @@ digest(PG_FUNCTION_ARGS)
9597
}
9698

9799
/* check if given hash exists */
100+
PG_FUNCTION_INFO_V1(digest_exists);
101+
98102
Datum
99103
digest_exists(PG_FUNCTION_ARGS)
100104
{

contrib/pgcrypto/pgcrypto.sql.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
CREATE FUNCTION digest(text, text) RETURNS text
66
AS '@MODULE_FILENAME@',
7-
'digest' LANGUAGE 'newC';
7+
'digest' LANGUAGE 'C';
88

99
CREATE FUNCTION digest_exists(text) RETURNS bool
1010
AS '@MODULE_FILENAME@',
11-
'digest_exists' LANGUAGE 'newC';
11+
'digest_exists' LANGUAGE 'C';
1212

contrib/soundex/soundex.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/contrib/soundex/Attic/soundex.c,v 1.7 2000/10/04 19:25:34 petere Exp $ */
1+
/* $Header: /cvsroot/pgsql/contrib/soundex/Attic/soundex.c,v 1.8 2000/11/20 20:36:57 tgl Exp $ */
22
#include "postgres.h"
33
#include "fmgr.h"
44
#include "utils/builtins.h"
@@ -7,11 +7,9 @@
77
#include <stdio.h>
88

99

10-
Datum
11-
text_soundex(PG_FUNCTION_ARGS);
10+
Datum text_soundex(PG_FUNCTION_ARGS);
1211

13-
static void
14-
soundex(const char *instr, char *outstr);
12+
static void soundex(const char *instr, char *outstr);
1513

1614
#define SOUNDEX_LEN 4
1715

@@ -24,6 +22,8 @@ soundex(const char *instr, char *outstr);
2422
/*
2523
* SQL function: text_soundex(text) returns text
2624
*/
25+
PG_FUNCTION_INFO_V1(text_soundex);
26+
2727
Datum
2828
text_soundex(PG_FUNCTION_ARGS)
2929
{
@@ -36,6 +36,7 @@ text_soundex(PG_FUNCTION_ARGS)
3636

3737
PG_RETURN_TEXT_P(_textin(outstr));
3838
}
39+
3940
#endif /* not SOUNDEX_TEST */
4041

4142

contrib/soundex/soundex.sql.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CREATE FUNCTION text_soundex(text) RETURNS text
2-
AS '@MODULE_FILENAME@', 'text_soundex' LANGUAGE 'newC';
2+
AS '@MODULE_FILENAME@', 'text_soundex' LANGUAGE 'C';
33

44
CREATE FUNCTION soundex(text) RETURNS text
5-
AS '@MODULE_FILENAME@', 'text_soundex' LANGUAGE 'newC';
5+
AS '@MODULE_FILENAME@', 'text_soundex' LANGUAGE 'C';

contrib/spi/autoinc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
extern Datum autoinc(PG_FUNCTION_ARGS);
77

8+
PG_FUNCTION_INFO_V1(autoinc);
9+
810
Datum
911
autoinc(PG_FUNCTION_ARGS)
1012
{

contrib/spi/autoinc.sql.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ DROP FUNCTION autoinc();
33
CREATE FUNCTION autoinc()
44
RETURNS opaque
55
AS 'MODULE_PATHNAME'
6-
LANGUAGE 'newC';
6+
LANGUAGE 'C';

contrib/spi/insert_username.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
extern Datum insert_username(PG_FUNCTION_ARGS);
1414

15+
PG_FUNCTION_INFO_V1(insert_username);
16+
1517
Datum
1618
insert_username(PG_FUNCTION_ARGS)
1719
{

contrib/spi/insert_username.sql.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ DROP FUNCTION insert_username();
33
CREATE FUNCTION insert_username()
44
RETURNS opaque
55
AS 'MODULE_PATHNAME'
6-
LANGUAGE 'newC';
6+
LANGUAGE 'C';

contrib/spi/moddatetime.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ OH, me, I'm Terry Mackintosh <terry@terrym.com>
1717

1818
extern Datum moddatetime(PG_FUNCTION_ARGS);
1919

20+
PG_FUNCTION_INFO_V1(moddatetime);
21+
2022
Datum
2123
moddatetime(PG_FUNCTION_ARGS)
2224
{

contrib/spi/moddatetime.sql.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ DROP FUNCTION moddatetime();
33
CREATE FUNCTION moddatetime()
44
RETURNS opaque
55
AS 'MODULE_PATHNAME'
6-
LANGUAGE 'newC';
6+
LANGUAGE 'C';

contrib/spi/refint.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ static EPlan *find_plan(char *ident, EPlan ** eplan, int *nplans);
3636
* check_primary_key ('Fkey1', 'Fkey2', 'Ptable', 'Pkey1', 'Pkey2').
3737
*/
3838

39+
PG_FUNCTION_INFO_V1(check_primary_key);
40+
3941
Datum
4042
check_primary_key(PG_FUNCTION_ARGS)
4143
{
@@ -216,6 +218,8 @@ check_primary_key(PG_FUNCTION_ARGS)
216218
* 'Ftable1', 'Fkey11', 'Fkey12', 'Ftable2', 'Fkey21', 'Fkey22').
217219
*/
218220

221+
PG_FUNCTION_INFO_V1(check_foreign_key);
222+
219223
Datum
220224
check_foreign_key(PG_FUNCTION_ARGS)
221225
{

contrib/spi/refint.sql.in

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ DROP FUNCTION check_foreign_key ();
44
CREATE FUNCTION check_primary_key ()
55
RETURNS opaque
66
AS 'MODULE_PATHNAME'
7-
LANGUAGE 'newC'
8-
;
7+
LANGUAGE 'C';
98

109
CREATE FUNCTION check_foreign_key ()
1110
RETURNS opaque
1211
AS 'MODULE_PATHNAME'
13-
LANGUAGE 'newC'
14-
;
12+
LANGUAGE 'C';

contrib/spi/timetravel.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ static EPlan *find_plan(char *ident, EPlan ** eplan, int *nplans);
4747
* timetravel ('date_on', 'date_off').
4848
*/
4949

50+
PG_FUNCTION_INFO_V1(timetravel);
51+
5052
Datum
5153
timetravel(PG_FUNCTION_ARGS)
5254
{
@@ -326,6 +328,8 @@ timetravel(PG_FUNCTION_ARGS)
326328
* set_timetravel (relname, on) --
327329
* turn timetravel for specified relation ON/OFF
328330
*/
331+
PG_FUNCTION_INFO_V1(set_timetravel);
332+
329333
Datum
330334
set_timetravel(PG_FUNCTION_ARGS)
331335
{

contrib/spi/timetravel.sql.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ DROP FUNCTION set_timetravel(name, int4);
44
CREATE FUNCTION timetravel()
55
RETURNS opaque
66
AS 'MODULE_PATHNAME'
7-
LANGUAGE 'newC';
7+
LANGUAGE 'C';
88

99
CREATE FUNCTION set_timetravel(name, int4)
1010
RETURNS int4
1111
AS 'MODULE_PATHNAME'
12-
LANGUAGE 'newC' WITH (isStrict);
12+
LANGUAGE 'C' WITH (isStrict);

doc/src/sgml/ref/create_function.sgml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_function.sgml,v 1.19 2000/11/02 19:26:44 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_function.sgml,v 1.20 2000/11/20 20:36:46 tgl Exp $
33
Postgres documentation
44
-->
55

@@ -119,8 +119,7 @@ CREATE FUNCTION <replaceable class="parameter">name</replaceable> ( [ <replaceab
119119
<listitem>
120120
<para>
121121
May be '<literal>sql</literal>',
122-
'<literal>C</literal>', '<literal>newC</literal>',
123-
'<literal>internal</literal>', '<literal>newinternal</literal>',
122+
'<literal>C</literal>', '<literal>internal</literal>',
124123
or '<replaceable class="parameter">plname</replaceable>',
125124
where '<replaceable class="parameter">plname</replaceable>'
126125
is the name of a created procedural language. See
@@ -258,7 +257,7 @@ CREATE
258257
</para>
259258

260259
<para>
261-
Two <literal>internal</literal> or <literal>newinternal</literal>
260+
Two <literal>internal</literal>
262261
functions cannot have the same C name without causing
263262
errors at link time. To get around that, give them different C names
264263
(for example, use the argument types as part of the C names), then

doc/src/sgml/ref/create_language.sgml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_language.sgml,v 1.13 2000/11/04 21:04:54 momjian Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_language.sgml,v 1.14 2000/11/20 20:36:46 tgl Exp $
33
Postgres documentation
44
-->
55

@@ -163,7 +163,8 @@ ERROR: PL handler function <replaceable class="parameter">funcname</replaceable
163163
<note>
164164
<para>
165165
In <productname>Postgres</productname> 7.1 and later, call handlers
166-
must adhere to the "new style" function manager interface.
166+
must adhere to the "version 1" function manager interface, not the
167+
old-style interface.
167168
</para>
168169
</note>
169170

@@ -180,7 +181,7 @@ ERROR: PL handler function <replaceable class="parameter">funcname</replaceable
180181
</para>
181182

182183
<para>
183-
The call handler is called in the same way as any other new-style
184+
The call handler is called in the same way as any other
184185
function: it receives a pointer to a FunctionCallInfoData struct
185186
containing argument values and information about the called function,
186187
and it is expected to return a Datum result (and possibly set the
@@ -269,18 +270,17 @@ ERROR: PL handler function <replaceable class="parameter">funcname</replaceable
269270
lanname | lanispl | lanpltrusted | lanplcallfoid | lancompiler
270271
-------------+---------+--------------+---------------+-------------
271272
internal | f | f | 0 | n/a
272-
newinternal | f | f | 0 | n/a
273273
C | f | f | 0 | /bin/cc
274-
newC | f | f | 0 | /bin/cc
275274
sql | f | f | 0 | postgres
276275
</computeroutput>
277276
</programlisting>
278277
</para>
279278

280279
<para>
281280
The call handler for a procedural language must normally be written
282-
in C and registered as 'newinternal' or 'newC' language, depending
281+
in C and registered as 'internal' or 'C' language, depending
283282
on whether it is linked into the backend or dynamically loaded.
283+
The call handler cannot use the old-style 'C' function interface.
284284
</para>
285285

286286
<para>
@@ -306,6 +306,8 @@ ERROR: PL handler function <replaceable class="parameter">funcname</replaceable
306306
#include "catalog/pg_proc.h"
307307
#include "catalog/pg_type.h"
308308

309+
PG_FUNCTION_INFO_V1(plsample_call_handler);
310+
309311
Datum
310312
plsample_call_handler(PG_FUNCTION_ARGS)
311313
{
@@ -344,7 +346,7 @@ plsample_call_handler(PG_FUNCTION_ARGS)
344346
<programlisting>
345347
CREATE FUNCTION plsample_call_handler () RETURNS opaque
346348
AS '/usr/local/pgsql/lib/plsample.so'
347-
LANGUAGE 'newC';
349+
LANGUAGE 'C';
348350
CREATE PROCEDURAL LANGUAGE 'plsample'
349351
HANDLER plsample_call_handler
350352
LANCOMPILER 'PL/Sample';

0 commit comments

Comments
 (0)