summaryrefslogtreecommitdiff
path: root/contrib/spi
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/spi')
-rw-r--r--contrib/spi/autoinc.c4
-rw-r--r--contrib/spi/insert_username.c4
-rw-r--r--contrib/spi/moddatetime.c9
-rw-r--r--contrib/spi/refint.c72
-rw-r--r--contrib/spi/timetravel.c23
5 files changed, 52 insertions, 60 deletions
diff --git a/contrib/spi/autoinc.c b/contrib/spi/autoinc.c
index b6e0c643316..bad7c527354 100644
--- a/contrib/spi/autoinc.c
+++ b/contrib/spi/autoinc.c
@@ -73,8 +73,8 @@ autoinc(PG_FUNCTION_ARGS)
if (SPI_gettypeid(tupdesc, attnum) != INT4OID)
ereport(ERROR,
(errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
- errmsg("attribute \"%s\" of \"%s\" must be type INT4",
- args[i], relname)));
+ errmsg("attribute \"%s\" of \"%s\" must be type INT4",
+ args[i], relname)));
val = DatumGetInt32(SPI_getbinval(rettuple, tupdesc, attnum, &isnull));
diff --git a/contrib/spi/insert_username.c b/contrib/spi/insert_username.c
index 237b14d25c2..ce8c21f9beb 100644
--- a/contrib/spi/insert_username.c
+++ b/contrib/spi/insert_username.c
@@ -65,7 +65,7 @@ insert_username(PG_FUNCTION_ARGS)
if (attnum < 0)
ereport(ERROR,
(errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
- errmsg("\"%s\" has no attribute \"%s\"", relname, args[0])));
+ errmsg("\"%s\" has no attribute \"%s\"", relname, args[0])));
if (SPI_gettypeid(tupdesc, attnum) != TEXTOID)
ereport(ERROR,
@@ -75,7 +75,7 @@ insert_username(PG_FUNCTION_ARGS)
/* create fields containing name */
newval = DirectFunctionCall1(textin,
- CStringGetDatum(GetUserNameFromId(GetUserId())));
+ CStringGetDatum(GetUserNameFromId(GetUserId())));
/* construct new tuple */
rettuple = SPI_modifytuple(rel, rettuple, 1, &attnum, &newval, NULL);
diff --git a/contrib/spi/moddatetime.c b/contrib/spi/moddatetime.c
index f3a97e1c81b..14556a85141 100644
--- a/contrib/spi/moddatetime.c
+++ b/contrib/spi/moddatetime.c
@@ -76,9 +76,8 @@ moddatetime(PG_FUNCTION_ARGS)
Int32GetDatum(-1));
/*
- * This gets the position in the tuple of the field we want. args[0]
- * being the name of the field to update, as passed in from the
- * trigger.
+ * This gets the position in the tuple of the field we want. args[0] being
+ * the name of the field to update, as passed in from the trigger.
*/
attnum = SPI_fnumber(tupdesc, args[0]);
@@ -100,8 +99,8 @@ moddatetime(PG_FUNCTION_ARGS)
if (SPI_gettypeid(tupdesc, attnum) != TIMESTAMPOID)
ereport(ERROR,
(errcode(ERRCODE_TRIGGERED_ACTION_EXCEPTION),
- errmsg("attribute \"%s\" of \"%s\" must be type TIMESTAMP",
- args[0], relname)));
+ errmsg("attribute \"%s\" of \"%s\" must be type TIMESTAMP",
+ args[0], relname)));
/* 1 is the number of items in the arrays attnum and newdt.
attnum is the positional number of the field to be updated.
diff --git a/contrib/spi/refint.c b/contrib/spi/refint.c
index bc358f6eb44..8163f8ebaf4 100644
--- a/contrib/spi/refint.c
+++ b/contrib/spi/refint.c
@@ -114,8 +114,8 @@ check_primary_key(PG_FUNCTION_ARGS)
kvals = (Datum *) palloc(nkeys * sizeof(Datum));
/*
- * Construct ident string as TriggerName $ TriggeredRelationId and try
- * to find prepared execution plan.
+ * Construct ident string as TriggerName $ TriggeredRelationId and try to
+ * find prepared execution plan.
*/
snprintf(ident, sizeof(ident), "%s$%u", trigger->tgname, rel->rd_id);
plan = find_plan(ident, &PPlans, &nPPlans);
@@ -134,16 +134,16 @@ check_primary_key(PG_FUNCTION_ARGS)
if (fnumber < 0)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
- errmsg("there is no attribute \"%s\" in relation \"%s\"",
- args[i], SPI_getrelname(rel))));
+ errmsg("there is no attribute \"%s\" in relation \"%s\"",
+ args[i], SPI_getrelname(rel))));
/* Well, get binary (in internal format) value of column */
kvals[i] = SPI_getbinval(tuple, tupdesc, fnumber, &isnull);
/*
- * If it's NULL then nothing to do! DON'T FORGET call SPI_finish
- * ()! DON'T FORGET return tuple! Executor inserts tuple you're
- * returning! If you return NULL then nothing will be inserted!
+ * If it's NULL then nothing to do! DON'T FORGET call SPI_finish ()!
+ * DON'T FORGET return tuple! Executor inserts tuple you're returning!
+ * If you return NULL then nothing will be inserted!
*/
if (isnull)
{
@@ -164,14 +164,14 @@ check_primary_key(PG_FUNCTION_ARGS)
char sql[8192];
/*
- * Construct query: SELECT 1 FROM _referenced_relation_ WHERE
- * Pkey1 = $1 [AND Pkey2 = $2 [...]]
+ * Construct query: SELECT 1 FROM _referenced_relation_ WHERE Pkey1 =
+ * $1 [AND Pkey2 = $2 [...]]
*/
snprintf(sql, sizeof(sql), "select 1 from %s where ", relname);
for (i = 0; i < nkeys; i++)
{
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), "%s = $%d %s",
- args[i + nkeys + 1], i + 1, (i < nkeys - 1) ? "and " : "");
+ args[i + nkeys + 1], i + 1, (i < nkeys - 1) ? "and " : "");
}
/* Prepare plan for query */
@@ -181,9 +181,8 @@ check_primary_key(PG_FUNCTION_ARGS)
elog(ERROR, "check_primary_key: SPI_prepare returned %d", SPI_result);
/*
- * Remember that SPI_prepare places plan in current memory context
- * - so, we have to save plan in Top memory context for latter
- * use.
+ * Remember that SPI_prepare places plan in current memory context -
+ * so, we have to save plan in Top memory context for latter use.
*/
pplan = SPI_saveplan(pplan);
if (pplan == NULL)
@@ -252,8 +251,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
EPlan *plan; /* prepared plan(s) */
Oid *argtypes = NULL; /* key types to prepare execution plan */
bool isnull; /* to know is some column NULL or not */
- bool isequal = true; /* are keys in both tuples equal (in
- * UPDATE) */
+ bool isequal = true; /* are keys in both tuples equal (in UPDATE) */
char ident[2 * NAMEDATALEN]; /* to identify myself */
int is_update = 0;
int ret;
@@ -287,9 +285,8 @@ check_foreign_key(PG_FUNCTION_ARGS)
trigtuple = trigdata->tg_trigtuple;
/*
- * But if this is UPDATE then we have to return tg_newtuple. Also, if
- * key in tg_newtuple is the same as in tg_trigtuple then nothing to
- * do.
+ * But if this is UPDATE then we have to return tg_newtuple. Also, if key
+ * in tg_newtuple is the same as in tg_trigtuple then nothing to do.
*/
is_update = 0;
if (TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
@@ -337,8 +334,8 @@ check_foreign_key(PG_FUNCTION_ARGS)
kvals = (Datum *) palloc(nkeys * sizeof(Datum));
/*
- * Construct ident string as TriggerName $ TriggeredRelationId and try
- * to find prepared execution plan(s).
+ * Construct ident string as TriggerName $ TriggeredRelationId and try to
+ * find prepared execution plan(s).
*/
snprintf(ident, sizeof(ident), "%s$%u", trigger->tgname, rel->rd_id);
plan = find_plan(ident, &FPlans, &nFPlans);
@@ -365,16 +362,16 @@ check_foreign_key(PG_FUNCTION_ARGS)
if (fnumber < 0)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
- errmsg("there is no attribute \"%s\" in relation \"%s\"",
- args[i], SPI_getrelname(rel))));
+ errmsg("there is no attribute \"%s\" in relation \"%s\"",
+ args[i], SPI_getrelname(rel))));
/* Well, get binary (in internal format) value of column */
kvals[i] = SPI_getbinval(trigtuple, tupdesc, fnumber, &isnull);
/*
- * If it's NULL then nothing to do! DON'T FORGET call SPI_finish
- * ()! DON'T FORGET return tuple! Executor inserts tuple you're
- * returning! If you return NULL then nothing will be inserted!
+ * If it's NULL then nothing to do! DON'T FORGET call SPI_finish ()!
+ * DON'T FORGET return tuple! Executor inserts tuple you're returning!
+ * If you return NULL then nothing will be inserted!
*/
if (isnull)
{
@@ -383,9 +380,9 @@ check_foreign_key(PG_FUNCTION_ARGS)
}
/*
- * If UPDATE then get column value from new tuple being inserted
- * and compare is this the same as old one. For the moment we use
- * string presentation of values...
+ * If UPDATE then get column value from new tuple being inserted and
+ * compare is this the same as old one. For the moment we use string
+ * presentation of values...
*/
if (newtuple != NULL)
{
@@ -473,7 +470,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
type = SPI_gettype(tupdesc, fn);
if ((strcmp(type, "text") && strcmp(type, "varchar") &&
- strcmp(type, "char") && strcmp(type, "bpchar") &&
+ strcmp(type, "char") && strcmp(type, "bpchar") &&
strcmp(type, "date") && strcmp(type, "timestamp")) == 0)
is_char_type = 1;
#ifdef DEBUG_QUERY
@@ -482,8 +479,7 @@ check_foreign_key(PG_FUNCTION_ARGS)
#endif
/*
- * is_char_type =1 i set ' ' for define a new
- * value
+ * is_char_type =1 i set ' ' for define a new value
*/
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql),
" %s = %s%s%s %s ",
@@ -503,8 +499,8 @@ check_foreign_key(PG_FUNCTION_ARGS)
/*
* For 'S'etnull action we construct UPDATE query - UPDATE
* _referencing_relation_ SET Fkey1 null [, Fkey2 null [...]]
- * WHERE Fkey1 = $1 [AND Fkey2 = $2 [...]] - to set key
- * columns in all referencing tuples to NULL.
+ * WHERE Fkey1 = $1 [AND Fkey2 = $2 [...]] - to set key columns in
+ * all referencing tuples to NULL.
*/
else if (action == 's')
{
@@ -532,9 +528,9 @@ check_foreign_key(PG_FUNCTION_ARGS)
elog(ERROR, "check_foreign_key: SPI_prepare returned %d", SPI_result);
/*
- * Remember that SPI_prepare places plan in current memory
- * context - so, we have to save plan in Top memory context
- * for latter use.
+ * Remember that SPI_prepare places plan in current memory context
+ * - so, we have to save plan in Top memory context for latter
+ * use.
*/
pplan = SPI_saveplan(pplan);
if (pplan == NULL)
@@ -566,8 +562,8 @@ check_foreign_key(PG_FUNCTION_ARGS)
for (r = 0; r < nrefs; r++)
{
/*
- * For 'R'estrict we may to execute plan for one tuple only, for
- * other actions - for all tuples.
+ * For 'R'estrict we may to execute plan for one tuple only, for other
+ * actions - for all tuples.
*/
int tcount = (action == 'r') ? 1 : 0;
diff --git a/contrib/spi/timetravel.c b/contrib/spi/timetravel.c
index 0eae24a5769..84a11538540 100644
--- a/contrib/spi/timetravel.c
+++ b/contrib/spi/timetravel.c
@@ -245,8 +245,8 @@ timetravel(PG_FUNCTION_ARGS)
elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[a_time_off]);
/*
- * If DELETE/UPDATE of tuple with stop_date neq INFINITY then say
- * upper Executor to skip operation for this tuple
+ * If DELETE/UPDATE of tuple with stop_date neq INFINITY then say upper
+ * Executor to skip operation for this tuple
*/
if (newtuple != NULL)
{ /* UPDATE */
@@ -263,8 +263,7 @@ timetravel(PG_FUNCTION_ARGS)
relname, args[a_time_on], args[a_time_off]);
}
if (oldtimeoff != NOEND_ABSTIME)
- { /* current record is a deleted/updated
- * record */
+ { /* current record is a deleted/updated record */
pfree(relname);
return PointerGetDatum(NULL);
}
@@ -285,8 +284,7 @@ timetravel(PG_FUNCTION_ARGS)
}
/* change date column(s) */
- cvals[attnum[a_time_off] - 1] = newtimeoff; /* stop_date eq current
- * date */
+ cvals[attnum[a_time_off] - 1] = newtimeoff; /* stop_date eq current date */
cnulls[attnum[a_time_off] - 1] = ' ';
if (!newtuple)
@@ -299,8 +297,8 @@ timetravel(PG_FUNCTION_ARGS)
}
/*
- * Construct ident string as TriggerName $ TriggeredRelationId and try
- * to find prepared execution plan.
+ * Construct ident string as TriggerName $ TriggeredRelationId and try to
+ * find prepared execution plan.
*/
snprintf(ident, sizeof(ident), "%s$%u", trigger->tgname, rel->rd_id);
plan = find_plan(ident, &Plans, &nPlans);
@@ -339,9 +337,8 @@ timetravel(PG_FUNCTION_ARGS)
elog(ERROR, "timetravel (%s): SPI_prepare returned %d", relname, SPI_result);
/*
- * Remember that SPI_prepare places plan in current memory context
- * - so, we have to save plan in Top memory context for latter
- * use.
+ * Remember that SPI_prepare places plan in current memory context -
+ * so, we have to save plan in Top memory context for latter use.
*/
pplan = SPI_saveplan(pplan);
if (pplan == NULL)
@@ -398,8 +395,8 @@ timetravel(PG_FUNCTION_ARGS)
rettuple = SPI_modifytuple(rel, newtuple, chnattrs, chattrs, newvals, newnulls);
/*
- * SPI_copytuple allocates tmptuple in upper executor context -
- * have to free allocation using SPI_pfree
+ * SPI_copytuple allocates tmptuple in upper executor context - have
+ * to free allocation using SPI_pfree
*/
/* SPI_pfree(tmptuple); */
}