summaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/async.c3
-rw-r--r--src/backend/commands/command.c20
-rw-r--r--src/backend/commands/comment.c5
-rw-r--r--src/backend/commands/copy.c4
-rw-r--r--src/backend/commands/dbcommands.c3
-rw-r--r--src/backend/commands/define.c83
-rw-r--r--src/backend/commands/indexcmds.c5
-rw-r--r--src/backend/commands/proclang.c3
-rw-r--r--src/backend/commands/trigger.c10
-rw-r--r--src/backend/commands/user.c3
-rw-r--r--src/backend/commands/vacuum.c3
11 files changed, 75 insertions, 67 deletions
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index c045f09b83..8225f3a7ca 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.60 2000/05/14 03:18:35 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.61 2000/05/28 17:55:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -87,6 +87,7 @@
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
#include "miscadmin.h"
+#include "utils/fmgroids.h"
#include "utils/ps_status.h"
#include "utils/syscache.h"
#include "utils/trace.h"
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c
index 2b9f6a257b..4fb184b7f6 100644
--- a/src/backend/commands/command.c
+++ b/src/backend/commands/command.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.71 2000/04/12 17:14:57 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.72 2000/05/28 17:55:54 tgl Exp $
*
* NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated
@@ -40,6 +40,7 @@
#include "optimizer/prep.h"
#include "utils/acl.h"
#include "utils/builtins.h"
+#include "utils/fmgroids.h"
#include "utils/syscache.h"
#include "utils/temprel.h"
#include "commands/trigger.h"
@@ -614,12 +615,15 @@ AlterTableAlterColumn(const char *relationName,
HeapTuple tuple;
attr_rel = heap_openr(AttributeRelationName, AccessExclusiveLock);
- ScanKeyEntryInitialize(&scankeys[0], 0x0, Anum_pg_attribute_attrelid, F_OIDEQ,
+ ScanKeyEntryInitialize(&scankeys[0], 0x0,
+ Anum_pg_attribute_attrelid, F_OIDEQ,
ObjectIdGetDatum(myrelid));
- ScanKeyEntryInitialize(&scankeys[1], 0x0, Anum_pg_attribute_attnum, F_INT2EQ,
+ ScanKeyEntryInitialize(&scankeys[1], 0x0,
+ Anum_pg_attribute_attnum, F_INT2EQ,
Int16GetDatum(attnum));
- ScanKeyEntryInitialize(&scankeys[2], 0x0, Anum_pg_attribute_atthasdef, F_BOOLEQ,
- TRUE);
+ ScanKeyEntryInitialize(&scankeys[2], 0x0,
+ Anum_pg_attribute_atthasdef, F_BOOLEQ,
+ Int32GetDatum(TRUE));
scan = heap_beginscan(attr_rel, false, SnapshotNow, 3, scankeys);
AssertState(scan != NULL);
@@ -661,9 +665,11 @@ drop_default(Oid relid, int16 attnum)
HeapTuple tuple;
attrdef_rel = heap_openr(AttrDefaultRelationName, AccessExclusiveLock);
- ScanKeyEntryInitialize(&scankeys[0], 0x0, Anum_pg_attrdef_adrelid, F_OIDEQ,
+ ScanKeyEntryInitialize(&scankeys[0], 0x0,
+ Anum_pg_attrdef_adrelid, F_OIDEQ,
ObjectIdGetDatum(relid));
- ScanKeyEntryInitialize(&scankeys[1], 0x0, Anum_pg_attrdef_adnum, F_INT2EQ,
+ ScanKeyEntryInitialize(&scankeys[1], 0x0,
+ Anum_pg_attrdef_adnum, F_INT2EQ,
Int16GetDatum(attnum));
scan = heap_beginscan(attrdef_rel, false, SnapshotNow, 2, scankeys);
diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c
index 3fe7b6f634..f33189d3ee 100644
--- a/src/backend/commands/comment.c
+++ b/src/backend/commands/comment.c
@@ -27,11 +27,12 @@
#include "catalog/pg_type.h"
#include "commands/comment.h"
#include "miscadmin.h"
+#include "parser/parse.h"
#include "rewrite/rewriteRemove.h"
#include "utils/acl.h"
+#include "utils/fmgroids.h"
#include "utils/syscache.h"
-#include "../backend/parser/parse.h"
/*------------------------------------------------------------------
* Static Function Prototypes --
@@ -153,7 +154,7 @@ CreateComments(Oid oid, char *comment)
}
i = 0;
values[i++] = ObjectIdGetDatum(oid);
- values[i++] = (Datum) fmgr(F_TEXTIN, comment);
+ values[i++] = (Datum) textin(comment);
}
/*** Now, open pg_description and attempt to find the old tuple ***/
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 65dff8ed44..4285663a16 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.106 2000/05/18 01:52:45 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.107 2000/05/28 17:55:54 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -680,7 +680,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
indexNatts[i] = natts;
if (VARSIZE(&pgIndexP[i]->indpred) != 0)
{
- predString = fmgr(F_TEXTOUT, &pgIndexP[i]->indpred);
+ predString = textout(&pgIndexP[i]->indpred);
indexPred[i] = stringToNode(predString);
pfree(predString);
/* make dummy ExprContext for use by ExecQual */
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 4458edafaf..b08f654504 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.54 2000/05/25 06:53:43 ishii Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.55 2000/05/28 17:55:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -37,6 +37,7 @@
#include "storage/fd.h" /* for closeAllVfds */
#include "storage/sinval.h" /* for DatabaseHasActiveBackends */
#include "utils/builtins.h"
+#include "utils/fmgroids.h"
#include "utils/elog.h"
#include "utils/palloc.h"
#include "utils/rel.h"
diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c
index 5bc75faaec..da87287217 100644
--- a/src/backend/commands/define.c
+++ b/src/backend/commands/define.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.42 2000/05/12 18:51:59 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.43 2000/05/28 17:55:55 tgl Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
@@ -35,8 +35,6 @@
*/
#include <ctype.h>
#include <math.h>
-#include <sys/stat.h>
-
#include "postgres.h"
@@ -66,18 +64,20 @@ static void
case_translate_language_name(const char *input, char *output)
{
/*-------------------------------------------------------------------------
- Translate the input language name to lower case, except if it's C,
- translate to upper case.
+ Translate the input language name to lower case, except if it's "C",
+ translate to upper case, or "newC", translate to that spelling.
--------------------------------------------------------------------------*/
int i;
- for (i = 0; i < NAMEDATALEN && input[i]; ++i)
+ for (i = 0; i < NAMEDATALEN-1 && input[i]; ++i)
output[i] = tolower(input[i]);
output[i] = '\0';
if (strcmp(output, "c") == 0)
output[0] = 'C';
+ else if (strcmp(output, "newc") == 0)
+ output[3] = 'C';
}
@@ -108,9 +108,10 @@ compute_return_type(const Node *returnType,
static void
-compute_full_attributes(List *parameters, int32 *byte_pct_p,
- int32 *perbyte_cpu_p, int32 *percall_cpu_p,
- int32 *outin_ratio_p, bool *canCache_p)
+compute_full_attributes(List *parameters,
+ int32 *byte_pct_p, int32 *perbyte_cpu_p,
+ int32 *percall_cpu_p, int32 *outin_ratio_p,
+ bool *canCache_p, bool *isStrict_p)
{
/*--------------------------------------------------------------------------
Interpret the parameters *parameters and return their contents as
@@ -119,14 +120,20 @@ compute_full_attributes(List *parameters, int32 *byte_pct_p,
These parameters supply optional information about a function.
All have defaults if not specified.
- Note: as of version 6.6, canCache is used (if set, the optimizer's
- constant-folder is allowed to pre-evaluate the function if all its
- inputs are constant). The other four are not used. They used to be
+ Note: currently, only two of these parameters actually do anything:
+
+ * canCache means the optimizer's constant-folder is allowed to
+ pre-evaluate the function when all its inputs are constants.
+
+ * isStrict means the function should not be called when any NULL
+ inputs are present; instead a NULL result value should be assumed.
+
+ The other four parameters are not used anywhere. They used to be
used in the "expensive functions" optimizer, but that's been dead code
for a long time.
- Since canCache is useful for any function, we now allow attributes to be
- supplied for all functions regardless of language.
+ Since canCache and isStrict are useful for any function, we now allow
+ attributes to be supplied for all functions regardless of language.
---------------------------------------------------------------------------*/
List *pl;
@@ -136,6 +143,7 @@ compute_full_attributes(List *parameters, int32 *byte_pct_p,
*percall_cpu_p = PERCALL_CPU;
*outin_ratio_p = OUTIN_RATIO;
*canCache_p = false;
+ *isStrict_p = false;
foreach(pl, parameters)
{
@@ -143,6 +151,8 @@ compute_full_attributes(List *parameters, int32 *byte_pct_p,
if (strcasecmp(param->defname, "iscachable") == 0)
*canCache_p = true;
+ else if (strcasecmp(param->defname, "isstrict") == 0)
+ *isStrict_p = true;
else if (strcasecmp(param->defname, "trusted") == 0)
{
@@ -182,24 +192,17 @@ static void
interpret_AS_clause(const char *languageName, const List *as,
char **prosrc_str_p, char **probin_str_p)
{
- struct stat stat_buf;
-
Assert(as != NIL);
- if (strcmp(languageName, "C") == 0)
+ if (strcmp(languageName, "C") == 0 ||
+ strcmp(languageName, "newC") == 0)
{
/*
* For "C" language, store the file name in probin and, when
- * given, the link symbol name in prosrc. But first, stat the
- * file to make sure it's there!
+ * given, the link symbol name in prosrc.
*/
-
- if (stat(strVal(lfirst(as)), &stat_buf) == -1)
- elog(ERROR, "stat failed on file '%s': %m", strVal(lfirst(as)));
-
*probin_str_p = strVal(lfirst(as));
-
if (lnext(as) == NULL)
*prosrc_str_p = "-";
else
@@ -239,8 +242,8 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest)
char languageName[NAMEDATALEN];
/*
- * name of language of function, with case adjusted: "C", "internal",
- * or "SQL"
+ * name of language of function, with case adjusted: "C", "newC",
+ * "internal", "newinternal", "sql", etc.
*/
bool returnsSet;
@@ -257,19 +260,21 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest)
perbyte_cpu,
percall_cpu,
outin_ratio;
- bool canCache;
-
+ bool canCache,
+ isStrict;
case_translate_language_name(stmt->language, languageName);
if (strcmp(languageName, "C") == 0 ||
- strcmp(languageName, "internal") == 0)
+ strcmp(languageName, "newC") == 0 ||
+ strcmp(languageName, "internal") == 0 ||
+ strcmp(languageName, "newinternal") == 0)
{
if (!superuser())
elog(ERROR,
"Only users with Postgres superuser privilege are "
- "permitted to create a function "
- "in the '%s' language. Others may use the 'sql' language "
+ "permitted to create a function in the '%s' language.\n\t"
+ "Others may use the 'sql' language "
"or the created procedural languages.",
languageName);
}
@@ -288,28 +293,23 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest)
0, 0, 0);
if (!HeapTupleIsValid(languageTuple))
- {
-
elog(ERROR,
"Unrecognized language specified in a CREATE FUNCTION: "
- "'%s'. Recognized languages are sql, C, internal "
- "and the created procedural languages.",
+ "'%s'.\n\tRecognized languages are sql, C, newC, "
+ "internal, newinternal, and created procedural languages.",
languageName);
- }
/* Check that this language is a PL */
languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
if (!(languageStruct->lanispl))
- {
elog(ERROR,
"Language '%s' isn't defined as PL", languageName);
- }
/*
* Functions in untrusted procedural languages are restricted to
* be defined by postgres superusers only
*/
- if (languageStruct->lanpltrusted == false && !superuser())
+ if (!languageStruct->lanpltrusted && !superuser())
{
elog(ERROR, "Only users with Postgres superuser privilege "
"are permitted to create a function in the '%s' "
@@ -324,7 +324,7 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest)
compute_full_attributes(stmt->withClause,
&byte_pct, &perbyte_cpu, &percall_cpu,
- &outin_ratio, &canCache);
+ &outin_ratio, &canCache, &isStrict);
interpret_AS_clause(languageName, stmt->as, &prosrc_str, &probin_str);
@@ -338,8 +338,9 @@ CreateFunction(ProcedureStmt *stmt, CommandDest dest)
languageName,
prosrc_str, /* converted to text later */
probin_str, /* converted to text later */
- canCache,
true, /* (obsolete "trusted") */
+ canCache,
+ isStrict,
byte_pct,
perbyte_cpu,
percall_cpu,
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 16ad849d8f..826efa40bb 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.26 2000/04/25 10:38:38 inoue Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.27 2000/05/28 17:55:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -37,6 +37,7 @@
#include "parser/parse_func.h"
#include "parser/parse_type.h"
#include "utils/builtins.h"
+#include "utils/fmgroids.h"
#include "utils/syscache.h"
#include "miscadmin.h" /* ReindexDatabase() */
#include "utils/portal.h" /* ReindexDatabase() */
@@ -298,7 +299,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
{
char *predString;
- predString = fmgr(F_TEXTOUT, &index->indpred);
+ predString = textout(&index->indpred);
oldPred = stringToNode(predString);
pfree(predString);
}
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c
index 47d2201c82..9b5f7c1ddf 100644
--- a/src/backend/commands/proclang.c
+++ b/src/backend/commands/proclang.c
@@ -17,6 +17,7 @@
#include "catalog/pg_shadow.h"
#include "commands/proclang.h"
#include "fmgr.h"
+#include "utils/builtins.h"
#include "utils/syscache.h"
@@ -119,7 +120,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
values[i++] = Int8GetDatum((bool) 1);
values[i++] = Int8GetDatum(stmt->pltrusted);
values[i++] = ObjectIdGetDatum(procTup->t_data->t_oid);
- values[i++] = (Datum) fmgr(F_TEXTIN, stmt->plcompiler);
+ values[i++] = (Datum) textin(stmt->plcompiler);
rel = heap_openr(LanguageRelationName, RowExclusiveLock);
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index c79ce0cea5..49f5570e8f 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.64 2000/04/16 04:25:42 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.65 2000/05/28 17:55:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -27,6 +27,7 @@
#include "miscadmin.h"
#include "utils/acl.h"
#include "utils/builtins.h"
+#include "utils/fmgroids.h"
#include "utils/inval.h"
#include "utils/syscache.h"
#include "utils/tqual.h"
@@ -757,16 +758,9 @@ equalTriggerDescs(TriggerDesc *trigdesc1, TriggerDesc *trigdesc2)
static HeapTuple
ExecCallTriggerFunc(Trigger *trigger)
{
-
if (trigger->tgfunc.fn_addr == NULL)
fmgr_info(trigger->tgfoid, &trigger->tgfunc);
- if (trigger->tgfunc.fn_plhandler != NULL)
- {
- return (HeapTuple) (*(trigger->tgfunc.fn_plhandler))
- (&trigger->tgfunc);
- }
-
return (HeapTuple) ((*fmgr_faddr(&trigger->tgfunc)) ());
}
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 2e01e6e202..ea5f457448 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: user.c,v 1.53 2000/05/04 20:06:07 tgl Exp $
+ * $Id: user.c,v 1.54 2000/05/28 17:55:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -33,6 +33,7 @@
#include "utils/acl.h"
#include "utils/array.h"
#include "utils/builtins.h"
+#include "utils/fmgroids.h"
#include "utils/syscache.h"
static void CheckPgUserAclNotNull(void);
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 0c0c5f4785..3a9b972b9e 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.148 2000/05/19 03:22:29 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.149 2000/05/28 17:55:55 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -38,6 +38,7 @@
#include "tcop/tcopprot.h"
#include "utils/acl.h"
#include "utils/builtins.h"
+#include "utils/fmgroids.h"
#include "utils/inval.h"
#include "utils/portal.h"
#include "utils/relcache.h"