aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/ascii.c17
-rw-r--r--src/backend/utils/adt/formatting.c225
-rw-r--r--src/backend/utils/adt/numeric.c333
-rw-r--r--src/backend/utils/adt/pg_lzcompress.c204
-rw-r--r--src/backend/utils/adt/ri_triggers.c731
-rw-r--r--src/backend/utils/adt/ruleutils.c158
-rw-r--r--src/backend/utils/init/postinit.c23
-rw-r--r--src/backend/utils/misc/database.c42
8 files changed, 701 insertions, 1032 deletions
diff --git a/src/backend/utils/adt/ascii.c b/src/backend/utils/adt/ascii.c
index bdcd24e44e0..234651aebab 100644
--- a/src/backend/utils/adt/ascii.c
+++ b/src/backend/utils/adt/ascii.c
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
* ascii.c
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.7 2001/03/22 03:59:49 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ascii.c,v 1.8 2001/03/22 06:16:17 momjian Exp $
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
*
@@ -80,27 +80,27 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int
if (enc == LATIN1)
{
- /* ----------
+
+ /*
* ISO-8859-1 <range: 160 -- 255>
- * ----------
*/
ascii = " cL Y \"Ca -R 'u ., ?AAAAAAACEEEEIIII NOOOOOxOUUUUYTBaaaaaaaceeeeiiii nooooo/ouuuuyty";
range = RANGE_160;
}
else if (enc == LATIN2)
{
- /* ----------
+
+ /*
* ISO-8859-2 <range: 160 -- 255>
- * ----------
*/
ascii = " A L LS \"SSTZ-ZZ a,l'ls ,sstz\"zzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTBraaaalccceeeeiiddnnoooo/ruuuuyt.";
range = RANGE_160;
}
else if (enc == WIN1250)
{
- /* ----------
+
+ /*
* Window CP1250 <range: 128 -- 255>
- * ----------
*/
ascii = " ' \" %S<STZZ `'\"\".-- s>stzz L A \"CS -RZ ,l'u .,as L\"lzRAAAALCCCEEEEIIDDNNOOOOxRUUUUYTBraaaalccceeeeiiddnnoooo/ruuuuyt ";
range = RANGE_128;
@@ -111,9 +111,8 @@ pg_to_ascii(unsigned char *src, unsigned char *src_end, unsigned char *desc, int
pg_encoding_to_char(enc));
}
- /* ----------
+ /*
* Encode
- * ----------
*/
for (x = src; x <= src_end; x++)
{
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index bebe8240144..0946ea9e496 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
* formatting.c
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.34 2001/03/22 03:59:50 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.35 2001/03/22 06:16:17 momjian Exp $
*
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
@@ -1132,9 +1132,8 @@ parse_format(FormatNode *node, char *str, KeyWord *kw,
{
suffix = 0;
- /* ----------
+ /*
* Prefix
- * ----------
*/
if (ver == DCH_TYPE && (s = suff_search(str, suf, SUFFTYPE_PREFIX)) != NULL)
{
@@ -1143,9 +1142,8 @@ parse_format(FormatNode *node, char *str, KeyWord *kw,
str += s->len;
}
- /* ----------
+ /*
* Keyword
- * ----------
*/
if (*str && (n->key = index_seq_search(str, kw, index)) != NULL)
{
@@ -1156,16 +1154,14 @@ parse_format(FormatNode *node, char *str, KeyWord *kw,
if (n->key->len)
str += n->key->len;
- /* ----------
+ /*
* NUM version: Prepare global NUMDesc struct
- * ----------
*/
if (ver == NUM_TYPE)
NUMDesc_prepare(Num, n);
- /* ----------
+ /*
* Postfix
- * ----------
*/
if (ver == DCH_TYPE && *str && (s = suff_search(str, suf, SUFFTYPE_POSTFIX)) != NULL)
{
@@ -1178,9 +1174,8 @@ parse_format(FormatNode *node, char *str, KeyWord *kw,
else if (*str)
{
- /* ----------
+ /*
* Special characters '\' and '"'
- * ----------
*/
if (*str == '"' && last != '\\')
{
@@ -1258,9 +1253,8 @@ DCH_processor(FormatNode *node, char *inout, int flag)
char *s;
- /* ----------
+ /*
* Zeroing global flags
- * ----------
*/
DCH_global_flag = 0;
@@ -1270,9 +1264,8 @@ DCH_processor(FormatNode *node, char *inout, int flag)
{
int len;
- /* ----------
+ /*
* Call node action function
- * ----------
*/
len = n->key->action(n->key->id, s, n->suffix, flag, n);
if (len > 0)
@@ -1284,18 +1277,17 @@ DCH_processor(FormatNode *node, char *inout, int flag)
else
{
- /* ----------
+ /*
* Remove to output char from input in TO_CHAR
- * ----------
*/
if (flag == TO_CHAR)
*s = n->character;
else
{
- /* ----------
+
+ /*
* Skip blank space in FROM_CHAR's input
- * ----------
*/
if (isspace((unsigned char) n->character) && IS_FX == 0)
{
@@ -1893,11 +1885,10 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node)
p_inout = inout;
- /* ----------
+ /*
* In the FROM-char is not difference between "January" or "JANUARY"
- * or "january", all is before search convert to "first-upper".
- * This convention is used for MONTH, MON, DAY, DY
- * ----------
+ * or "january", all is before search convert to "first-upper". This
+ * convention is used for MONTH, MON, DAY, DY
*/
if (flag == FROM_CHAR)
{
@@ -2459,9 +2450,8 @@ DCH_cache_getnew(char *str)
ent->age = (++DCHCounter);
}
- /* ----------
+ /*
* Cache is full - needs remove any older entry
- * ----------
*/
if (n_DCHCache > DCH_CACHE_FIELDS)
{
@@ -2583,24 +2573,21 @@ timestamp_to_char(PG_FUNCTION_ARGS)
tm->tm_wday = (date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + 1) % 7;
tm->tm_yday = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(tm->tm_year, 1, 1) + 1;
- /* ----------
+ /*
* Convert fmt to C string
- * ----------
*/
str = (char *) palloc(len + 1);
memcpy(str, VARDATA(fmt), len);
*(str + len) = '\0';
- /* ----------
+ /*
* Allocate result
- * ----------
*/
result = (text *) palloc((len * DCH_MAX_ITEM_SIZ) + 1 + VARHDRSZ);
- /* ----------
+ /*
* Allocate new memory if format picture is bigger than static cache
* and not use cache (call parser always) - flag=1 show this variant
- * ----------
*/
if (len > DCH_CACHE_SIZE)
{
@@ -2616,9 +2603,8 @@ timestamp_to_char(PG_FUNCTION_ARGS)
else
{
- /* ----------
+ /*
* Use cache buffers
- * ----------
*/
DCHCacheEntry *ent;
@@ -2629,10 +2615,9 @@ timestamp_to_char(PG_FUNCTION_ARGS)
ent = DCH_cache_getnew(str);
- /* ----------
+ /*
* Not in the cache, must run parser and save a new
* format-picture to the cache.
- * ----------
*/
parse_format(ent->format, str, DCH_keywords,
DCH_suff, DCH_index, DCH_TYPE, NULL);
@@ -2654,10 +2639,9 @@ timestamp_to_char(PG_FUNCTION_ARGS)
pfree(str);
- /* ----------
+ /*
* for result is allocated max memory, which current format-picture
* needs, now it must be re-allocate to result real size
- * ----------
*/
if (!(len = strlen(VARDATA(result))))
{
@@ -2706,18 +2690,17 @@ to_timestamp(PG_FUNCTION_ARGS)
if (len)
{
- /* ----------
+ /*
* Convert fmt to C string
- * ----------
*/
str = (char *) palloc(len + 1);
memcpy(str, VARDATA(fmt), len);
*(str + len) = '\0';
- /* ----------
- * Allocate new memory if format picture is bigger than static cache
- * and not use cache (call parser always) - flag=1 show this variant
- * ----------
+ /*
+ * Allocate new memory if format picture is bigger than static
+ * cache and not use cache (call parser always) - flag=1 show this
+ * variant
*/
if (len > DCH_CACHE_SIZE)
{
@@ -2732,9 +2715,8 @@ to_timestamp(PG_FUNCTION_ARGS)
else
{
- /* ----------
+ /*
* Use cache buffers
- * ----------
*/
DCHCacheEntry *ent;
@@ -2745,11 +2727,10 @@ to_timestamp(PG_FUNCTION_ARGS)
ent = DCH_cache_getnew(str);
- /* ----------
+ /*
* Not in the cache, must run parser and save a new
* format-picture to the cache.
- * ----------
- */
+ */
parse_format(ent->format, str, DCH_keywords,
DCH_suff, DCH_index, DCH_TYPE, NULL);
@@ -2762,17 +2743,15 @@ to_timestamp(PG_FUNCTION_ARGS)
format = ent->format;
}
- /* ----------
+ /*
* Call action for each node in FormatNode tree
- * ----------
*/
#ifdef DEBUG_TO_FROM_CHAR
/* dump_node(format, len); */
#endif
- /* ----------
+ /*
* Convert date to C string
- * ----------
*/
date_len = VARSIZE(date_txt) - VARHDRSZ;
date_str = (char *) palloc(date_len + 1);
@@ -2787,10 +2766,9 @@ to_timestamp(PG_FUNCTION_ARGS)
pfree(format);
}
- /* --------------------------------------------------------------
- * Convert values that user define for FROM_CHAR (to_date/to_timestamp)
- * to standard 'tm'
- * ----------
+ /*
+ * Convert values that user define for FROM_CHAR
+ * (to_date/to_timestamp) to standard 'tm'
*/
#ifdef DEBUG_TO_FROM_CHAR
NOTICE_TMFC;
@@ -3050,9 +3028,8 @@ NUM_cache_getnew(char *str)
ent->age = (++NUMCounter);
}
- /* ----------
+ /*
* Cache is full - needs remove any older entry
- * ----------
*/
if (n_NUMCache > NUM_CACHE_FIELDS)
{
@@ -3156,18 +3133,16 @@ NUM_cache(int len, NUMDesc *Num, char *pars_str, int *flag)
FormatNode *format = NULL;
char *str;
- /* ----------
+ /*
* Convert VARDATA() to string
- * ----------
*/
str = (char *) palloc(len + 1);
memcpy(str, pars_str, len);
*(str + len) = '\0';
- /* ----------
+ /*
* Allocate new memory if format picture is bigger than static cache
* and not use cache (call parser always) - flag=1 show this variant
- * ----------
*/
if (len > NUM_CACHE_SIZE)
{
@@ -3186,9 +3161,8 @@ NUM_cache(int len, NUMDesc *Num, char *pars_str, int *flag)
else
{
- /* ----------
+ /*
* Use cache buffers
- * ----------
*/
NUMCacheEntry *ent;
@@ -3199,11 +3173,10 @@ NUM_cache(int len, NUMDesc *Num, char *pars_str, int *flag)
ent = NUM_cache_getnew(str);
- /* ----------
+ /*
* Not in the cache, must run parser and save a new
* format-picture to the cache.
- * ----------
- */
+ */
parse_format(ent->format, str, NUM_keywords,
NULL, NUM_index, NUM_TYPE, &ent->Num);
@@ -3213,9 +3186,8 @@ NUM_cache(int len, NUMDesc *Num, char *pars_str, int *flag)
format = ent->format;
- /* ----------
+ /*
* Copy cache to used struct
- * ----------
*/
Num->flag = ent->Num.flag;
Num->lsign = ent->Num.lsign;
@@ -3302,15 +3274,13 @@ NUM_prepare_locale(NUMProc *Np)
struct lconv *lconv;
- /* ----------
+ /*
* Get locales
- * ----------
*/
lconv = PGLC_localeconv();
- /* ----------
+ /*
* Positive / Negative number sign
- * ----------
*/
if (lconv->negative_sign && *lconv->negative_sign)
Np->L_negative_sign = lconv->negative_sign;
@@ -3322,27 +3292,24 @@ NUM_prepare_locale(NUMProc *Np)
else
Np->L_positive_sign = "+";
- /* ----------
+ /*
* Number thousands separator
- * ----------
*/
if (lconv->thousands_sep && *lconv->thousands_sep)
Np->L_thousands_sep = lconv->thousands_sep;
else
Np->L_thousands_sep = ",";
- /* ----------
+ /*
* Number decimal point
- * ----------
*/
if (lconv->decimal_point && *lconv->decimal_point)
Np->decimal = lconv->decimal_point;
else
Np->decimal = ".";
- /* ----------
+ /*
* Currency symbol
- * ----------
*/
if (lconv->currency_symbol && *lconv->currency_symbol)
Np->L_currency_symbol = lconv->currency_symbol;
@@ -3357,9 +3324,9 @@ NUM_prepare_locale(NUMProc *Np)
{
#endif
- /* ----------
+
+ /*
* Default values
- * ----------
*/
Np->L_negative_sign = "-";
Np->L_positive_sign = "+";
@@ -3423,9 +3390,8 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
if (OVERLOAD_TEST)
return;
- /* ----------
+ /*
* read sign
- * ----------
*/
if (*Np->number == ' ' && (id == NUM_0 || id == NUM_9 || NUM_S))
{
@@ -3433,9 +3399,9 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
#ifdef DEBUG_TO_FROM_CHAR
elog(DEBUG_elog_output, "Try read sign (%c).", *Np->inout_p);
#endif
- /* ----------
+
+ /*
* locale sign
- * ----------
*/
if (IS_LSIGN(Np->Num))
{
@@ -3464,9 +3430,9 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
#ifdef DEBUG_TO_FROM_CHAR
elog(DEBUG_elog_output, "Try read sipmle sign (%c).", *Np->inout_p);
#endif
- /* ----------
+
+ /*
* simple + - < >
- * ----------
*/
if (*Np->inout_p == '-' || (IS_BRACKET(Np->Num) &&
*Np->inout_p == '<'))
@@ -3487,9 +3453,8 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
if (OVERLOAD_TEST)
return;
- /* ----------
+ /*
* read digit
- * ----------
*/
if (isdigit((unsigned char) *Np->inout_p))
{
@@ -3507,9 +3472,8 @@ NUM_numpart_from_char(NUMProc *Np, int id, int plen)
elog(DEBUG_elog_output, "Read digit (%c).", *Np->inout_p);
#endif
- /* ----------
+ /*
* read decimal point
- * ----------
*/
}
else if (IS_DECIMAL(Np->Num))
@@ -3572,9 +3536,8 @@ NUM_numpart_to_char(NUMProc *Np, int id)
#endif
Np->num_in = FALSE;
- /* ----------
+ /*
* Write sign
- * ----------
*/
if (Np->num_curr == Np->sign_pos && Np->sign_wrote == FALSE)
{
@@ -3585,9 +3548,8 @@ NUM_numpart_to_char(NUMProc *Np, int id)
if (IS_LSIGN(Np->Num))
{
- /* ----------
+ /*
* Write locale SIGN
- * ----------
*/
if (Np->sign == '-')
strcpy(Np->inout_p, Np->L_negative_sign);
@@ -3620,9 +3582,9 @@ NUM_numpart_to_char(NUMProc *Np, int id)
(Np->num_curr == Np->num_count + (Np->num_pre ? 1 : 0)
+ (IS_DECIMAL(Np->Num) ? 1 : 0)))
{
- /* ----------
+
+ /*
* Write close BRACKET
- * ----------
*/
#ifdef DEBUG_TO_FROM_CHAR
elog(DEBUG_elog_output, "Writing bracket to position %d", Np->num_curr);
@@ -3631,9 +3593,8 @@ NUM_numpart_to_char(NUMProc *Np, int id)
++Np->inout_p;
}
- /* ----------
+ /*
* digits / FM / Zero / Dec. point
- * ----------
*/
if (id == NUM_9 || id == NUM_0 || id == NUM_D || id == NUM_DEC ||
(id == NUM_S && Np->num_curr < Np->num_pre))
@@ -3643,9 +3604,8 @@ NUM_numpart_to_char(NUMProc *Np, int id)
(Np->Num->zero_start > Np->num_curr || !IS_ZERO(Np->Num)))
{
- /* ----------
+ /*
* Write blank space
- * ----------
*/
if (!IS_FILLMODE(Np->Num))
{
@@ -3662,9 +3622,8 @@ NUM_numpart_to_char(NUMProc *Np, int id)
Np->Num->zero_start <= Np->num_curr)
{
- /* ----------
+ /*
* Write ZERO
- * ----------
*/
#ifdef DEBUG_TO_FROM_CHAR
elog(DEBUG_elog_output, "Writing zero to position %d", Np->num_curr);
@@ -3677,10 +3636,9 @@ NUM_numpart_to_char(NUMProc *Np, int id)
else
{
- /* ----------
- * Write Decinal point
- * ----------
- */
+ /*
+ * Write Decinal point
+ */
if (*Np->number_p == '.')
{
@@ -3708,9 +3666,8 @@ NUM_numpart_to_char(NUMProc *Np, int id)
else
{
- /* ----------
+ /*
* Write Digits
- * ----------
*/
if (Np->last_relevant && Np->number_p > Np->last_relevant &&
id != NUM_0)
@@ -3775,9 +3732,8 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
if (Np->Num->zero_start)
--Np->Num->zero_start;
- /* ----------
+ /*
* Roman correction
- * ----------
*/
if (IS_ROMAN(Np->Num))
{
@@ -3797,9 +3753,8 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
Np->Num->flag |= NUM_F_ROMAN;
}
- /* ----------
+ /*
* Sign
- * ----------
*/
if (type == FROM_CHAR)
{
@@ -3833,9 +3788,8 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
Np->sign_wrote = TRUE; /* needn't sign */
}
- /* ----------
+ /*
* Count
- * ----------
*/
Np->num_count = Np->Num->post + Np->Num->pre - 1;
@@ -3858,9 +3812,8 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
if (!Np->sign_wrote)
{
- /* ----------
+ /*
* Set SING position
- * ----------
*/
if (Np->Num->lsign == NUM_LSIGN_POST)
{
@@ -3875,9 +3828,8 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
else
Np->sign_pos = Np->num_pre && !IS_FILLMODE(Np->Num) ? Np->num_pre : 0;
- /* ----------
+ /*
* terrible Ora format
- * ----------
*/
if (!IS_ZERO(Np->Num) && *Np->number == '0' &&
!IS_FILLMODE(Np->Num) && Np->Num->post != 0)
@@ -3924,15 +3876,13 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
);
#endif
- /* ----------
+ /*
* Locale
- * ----------
*/
NUM_prepare_locale(Np);
- /* ----------
+ /*
* Processor direct cycle
- * ----------
*/
if (Np->type == FROM_CHAR)
Np->number_p = Np->number + 1; /* first char is space for sign */
@@ -3944,24 +3894,22 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
if (Np->type == FROM_CHAR)
{
- /* ----------
+
+ /*
* Check non-string inout end
- * ----------
*/
if (Np->inout_p >= Np->inout + plen)
break;
}
- /* ----------
+ /*
* Format pictures actions
- * ----------
*/
if (n->type == NODE_TYPE_ACTION)
{
- /* ----------
+ /*
* Create/reading digit/zero/blank/sing
- * ----------
*/
switch (n->key->id)
{
@@ -4145,9 +4093,9 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
}
else
{
- /* ----------
+
+ /*
* Remove to output char from input in TO_CHAR
- * ----------
*/
if (Np->type == TO_CHAR)
*Np->inout_p = n->character;
@@ -4169,9 +4117,8 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
else
*Np->number_p = '\0';
- /* ----------
+ /*
* Correction - precision of dec. number
- * ----------
*/
Np->Num->post = Np->read_post;
@@ -4213,10 +4160,9 @@ do { \
if (flag) \
pfree(format); \
\
- /* ---------- \
+ /*
* for result is allocated max memory, which current format-picture\
* needs, now it must be re-allocate to result real size \
- * ---------- \
*/ \
if (!(len = strlen(VARDATA(result)))) \
{ \
@@ -4300,9 +4246,8 @@ numeric_to_char(PG_FUNCTION_ARGS)
NUM_TOCHAR_prepare;
- /* ----------
+ /*
* On DateType depend part (numeric)
- * ----------
*/
if (IS_ROMAN(&Num))
{
@@ -4399,9 +4344,8 @@ int4_to_char(PG_FUNCTION_ARGS)
NUM_TOCHAR_prepare;
- /* ----------
+ /*
* On DateType depend part (int32)
- * ----------
*/
if (IS_ROMAN(&Num))
numstr = orgnum = int_to_roman(value);
@@ -4481,9 +4425,8 @@ int8_to_char(PG_FUNCTION_ARGS)
NUM_TOCHAR_prepare;
- /* ----------
+ /*
* On DateType depend part (int32)
- * ----------
*/
if (IS_ROMAN(&Num))
{
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index 4a16741bb91..4399ae554b3 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -5,7 +5,7 @@
*
* 1998 Jan Wieck
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.38 2001/03/22 03:59:52 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.39 2001/03/22 06:16:17 momjian Exp $
*
* ----------
*/
@@ -201,17 +201,15 @@ numeric_in(PG_FUNCTION_ARGS)
NumericVar value;
Numeric res;
- /* ----------
+ /*
* Check for NaN
- * ----------
*/
if (strcmp(str, "NaN") == 0)
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
- * Use set_var_from_str() to parse the input string
- * and return it in the packed DB storage format
- * ----------
+ /*
+ * Use set_var_from_str() to parse the input string and return it in
+ * the packed DB storage format
*/
init_var(&value);
set_var_from_str(str, &value);
@@ -238,21 +236,19 @@ numeric_out(PG_FUNCTION_ARGS)
NumericVar x;
char *str;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num))
PG_RETURN_CSTRING(pstrdup("NaN"));
- /* ----------
+ /*
* Get the number in the variable format.
*
- * Even if we didn't need to change format, we'd still need to copy
- * the value to have a modifiable copy for rounding. set_var_from_num()
+ * Even if we didn't need to change format, we'd still need to copy the
+ * value to have a modifiable copy for rounding. set_var_from_num()
* also guarantees there is extra digit space in case we produce a
* carry out from rounding.
- * ----------
*/
init_var(&x);
set_var_from_num(num, &x);
@@ -285,17 +281,15 @@ numeric(PG_FUNCTION_ARGS)
int maxweight;
NumericVar var;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
- * If the value isn't a valid type modifier, simply return a
- * copy of the input value
- * ----------
+ /*
+ * If the value isn't a valid type modifier, simply return a copy of
+ * the input value
*/
if (typmod < (int32) (VARHDRSZ))
{
@@ -304,20 +298,18 @@ numeric(PG_FUNCTION_ARGS)
PG_RETURN_NUMERIC(new);
}
- /* ----------
+ /*
* Get the precision and scale out of the typmod value
- * ----------
*/
tmp_typmod = typmod - VARHDRSZ;
precision = (tmp_typmod >> 16) & 0xffff;
scale = tmp_typmod & 0xffff;
maxweight = precision - scale;
- /* ----------
- * If the number is in bounds and due to the present result scale
- * no rounding could be necessary, just make a copy of the input
- * and modify its scale fields.
- * ----------
+ /*
+ * If the number is in bounds and due to the present result scale no
+ * rounding could be necessary, just make a copy of the input and
+ * modify its scale fields.
*/
if (num->n_weight < maxweight && scale >= num->n_rscale)
{
@@ -329,10 +321,9 @@ numeric(PG_FUNCTION_ARGS)
PG_RETURN_NUMERIC(new);
}
- /* ----------
- * We really need to fiddle with things - unpack the number into
- * a variable and let apply_typmod() do it.
- * ----------
+ /*
+ * We really need to fiddle with things - unpack the number into a
+ * variable and let apply_typmod() do it.
*/
init_var(&var);
@@ -359,16 +350,14 @@ numeric_abs(PG_FUNCTION_ARGS)
Numeric num = PG_GETARG_NUMERIC(0);
Numeric res;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
+ /*
* Do it the easy way directly on the packed format
- * ----------
*/
res = (Numeric) palloc(num->varlen);
memcpy(res, num, num->varlen);
@@ -385,25 +374,22 @@ numeric_uminus(PG_FUNCTION_ARGS)
Numeric num = PG_GETARG_NUMERIC(0);
Numeric res;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
+ /*
* Do it the easy way directly on the packed format
- * ----------
*/
res = (Numeric) palloc(num->varlen);
memcpy(res, num, num->varlen);
- /* ----------
- * The packed format is known to be totally zero digit trimmed
- * always. So we can identify a ZERO by the fact that there
- * are no digits at all. Do nothing to a zero.
- * ----------
+ /*
+ * The packed format is known to be totally zero digit trimmed always.
+ * So we can identify a ZERO by the fact that there are no digits at
+ * all. Do nothing to a zero.
*/
if (num->varlen != NUMERIC_HDRSZ)
{
@@ -425,29 +411,27 @@ numeric_sign(PG_FUNCTION_ARGS)
Numeric res;
NumericVar result;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num))
PG_RETURN_NUMERIC(make_result(&const_nan));
init_var(&result);
- /* ----------
- * The packed format is known to be totally zero digit trimmed
- * always. So we can identify a ZERO by the fact that there
- * are no digits at all.
- * ----------
+ /*
+ * The packed format is known to be totally zero digit trimmed always.
+ * So we can identify a ZERO by the fact that there are no digits at
+ * all.
*/
if (num->varlen == NUMERIC_HDRSZ)
set_var_from_var(&const_zero, &result);
else
{
- /* ----------
- * And if there are some, we return a copy of ONE
- * with the sign of our argument
- * ----------
+
+ /*
+ * And if there are some, we return a copy of ONE with the sign of
+ * our argument
*/
set_var_from_var(&const_one, &result);
result.sign = NUMERIC_SIGN(num);
@@ -477,23 +461,21 @@ numeric_round(PG_FUNCTION_ARGS)
NumericVar arg;
int i;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
- * Limit the scale value to avoid possible overflow in calculations below.
- * ----------
+ /*
+ * Limit the scale value to avoid possible overflow in calculations
+ * below.
*/
scale = MIN(NUMERIC_MAX_RESULT_SCALE,
MAX(-NUMERIC_MAX_RESULT_SCALE, scale));
- /* ----------
+ /*
* Unpack the argument and round it at the proper digit position
- * ----------
*/
init_var(&arg);
set_var_from_num(num, &arg);
@@ -533,17 +515,15 @@ numeric_round(PG_FUNCTION_ARGS)
}
}
- /* ----------
+ /*
* Set result's scale to something reasonable.
- * ----------
*/
scale = MIN(NUMERIC_MAX_DISPLAY_SCALE, MAX(0, scale));
arg.rscale = scale;
arg.dscale = scale;
- /* ----------
+ /*
* Return the rounded result
- * ----------
*/
res = make_result(&arg);
@@ -568,40 +548,36 @@ numeric_trunc(PG_FUNCTION_ARGS)
Numeric res;
NumericVar arg;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
- * Limit the scale value to avoid possible overflow in calculations below.
- * ----------
+ /*
+ * Limit the scale value to avoid possible overflow in calculations
+ * below.
*/
scale = MIN(NUMERIC_MAX_RESULT_SCALE,
MAX(-NUMERIC_MAX_RESULT_SCALE, scale));
- /* ----------
+ /*
* Unpack the argument and truncate it at the proper digit position
- * ----------
*/
init_var(&arg);
set_var_from_num(num, &arg);
arg.ndigits = MIN(arg.ndigits, MAX(0, arg.weight + scale + 1));
- /* ----------
+ /*
* Set result's scale to something reasonable.
- * ----------
*/
scale = MIN(NUMERIC_MAX_DISPLAY_SCALE, MAX(0, scale));
arg.rscale = scale;
arg.dscale = scale;
- /* ----------
+ /*
* Return the truncated result
- * ----------
*/
res = make_result(&arg);
@@ -931,18 +907,16 @@ numeric_add(PG_FUNCTION_ARGS)
NumericVar result;
Numeric res;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num1) || NUMERIC_IS_NAN(num2))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
- * Unpack the values, let add_var() compute the result
- * and return it. The internals of add_var() will automatically
- * set the correct result and display scales in the result.
- * ----------
+ /*
+ * Unpack the values, let add_var() compute the result and return it.
+ * The internals of add_var() will automatically set the correct
+ * result and display scales in the result.
*/
init_var(&arg1);
init_var(&arg2);
@@ -978,17 +952,15 @@ numeric_sub(PG_FUNCTION_ARGS)
NumericVar result;
Numeric res;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num1) || NUMERIC_IS_NAN(num2))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
- * Unpack the two arguments, let sub_var() compute the
- * result and return it.
- * ----------
+ /*
+ * Unpack the two arguments, let sub_var() compute the result and
+ * return it.
*/
init_var(&arg1);
init_var(&arg2);
@@ -1024,22 +996,19 @@ numeric_mul(PG_FUNCTION_ARGS)
NumericVar result;
Numeric res;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num1) || NUMERIC_IS_NAN(num2))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
- * Unpack the arguments, let mul_var() compute the result
- * and return it. Unlike add_var() and sub_var(), mul_var()
- * will round the result to the scale stored in global_rscale.
- * In the case of numeric_mul(), which is invoked for the *
- * operator on numerics, we set it to the exact representation
- * for the product (rscale = sum(rscale of arg1, rscale of arg2)
- * and the same for the dscale).
- * ----------
+ /*
+ * Unpack the arguments, let mul_var() compute the result and return
+ * it. Unlike add_var() and sub_var(), mul_var() will round the result
+ * to the scale stored in global_rscale. In the case of numeric_mul(),
+ * which is invoked for the * operator on numerics, we set it to the
+ * exact representation for the product (rscale = sum(rscale of arg1,
+ * rscale of arg2) and the same for the dscale).
*/
init_var(&arg1);
init_var(&arg2);
@@ -1081,16 +1050,14 @@ numeric_div(PG_FUNCTION_ARGS)
Numeric res;
int res_dscale;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num1) || NUMERIC_IS_NAN(num2))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
+ /*
* Unpack the arguments
- * ----------
*/
init_var(&arg1);
init_var(&arg2);
@@ -1122,9 +1089,8 @@ numeric_div(PG_FUNCTION_ARGS)
global_rscale = MAX(global_rscale, res_dscale + 4);
global_rscale = MIN(global_rscale, NUMERIC_MAX_RESULT_SCALE);
- /* ----------
+ /*
* Do the divide, set the display scale and return the result
- * ----------
*/
div_var(&arg1, &arg2, &result);
@@ -1192,16 +1158,14 @@ numeric_inc(PG_FUNCTION_ARGS)
NumericVar arg;
Numeric res;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
+ /*
* Compute the result and return it
- * ----------
*/
init_var(&arg);
@@ -1231,16 +1195,14 @@ numeric_smaller(PG_FUNCTION_ARGS)
NumericVar arg2;
Numeric res;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num1) || NUMERIC_IS_NAN(num2))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
+ /*
* Unpack the values, and decide which is the smaller one
- * ----------
*/
init_var(&arg1);
init_var(&arg2);
@@ -1275,16 +1237,14 @@ numeric_larger(PG_FUNCTION_ARGS)
NumericVar arg2;
Numeric res;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num1) || NUMERIC_IS_NAN(num2))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
+ /*
* Unpack the values, and decide which is the larger one
- * ----------
*/
init_var(&arg1);
init_var(&arg2);
@@ -1327,17 +1287,15 @@ numeric_sqrt(PG_FUNCTION_ARGS)
NumericVar result;
int res_dscale;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
- * Unpack the argument, determine the scales like for divide,
- * let sqrt_var() do the calculation and return the result.
- * ----------
+ /*
+ * Unpack the argument, determine the scales like for divide, let
+ * sqrt_var() do the calculation and return the result.
*/
init_var(&arg);
init_var(&result);
@@ -1378,16 +1336,14 @@ numeric_exp(PG_FUNCTION_ARGS)
NumericVar result;
int res_dscale;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
+ /*
* Same procedure like for sqrt().
- * ----------
*/
init_var(&arg);
init_var(&result);
@@ -1427,16 +1383,14 @@ numeric_ln(PG_FUNCTION_ARGS)
NumericVar result;
int res_dscale;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
+ /*
* Same procedure like for sqrt()
- * ----------
*/
init_var(&arg);
init_var(&result);
@@ -1478,16 +1432,14 @@ numeric_log(PG_FUNCTION_ARGS)
NumericVar result;
int res_dscale;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num1) || NUMERIC_IS_NAN(num2))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
+ /*
* Initialize things and calculate scales
- * ----------
*/
init_var(&arg1);
init_var(&arg2);
@@ -1501,9 +1453,8 @@ numeric_log(PG_FUNCTION_ARGS)
global_rscale = MAX(global_rscale, res_dscale + 4);
global_rscale = MIN(global_rscale, NUMERIC_MAX_RESULT_SCALE);
- /* ----------
+ /*
* Call log_var() to compute and return the result
- * ----------
*/
log_var(&arg1, &arg2, &result);
@@ -1536,16 +1487,14 @@ numeric_power(PG_FUNCTION_ARGS)
NumericVar result;
int res_dscale;
- /* ----------
+ /*
* Handle NaN
- * ----------
*/
if (NUMERIC_IS_NAN(num1) || NUMERIC_IS_NAN(num2))
PG_RETURN_NUMERIC(make_result(&const_nan));
- /* ----------
+ /*
* Initialize things and calculate scales
- * ----------
*/
init_var(&arg1);
init_var(&arg2);
@@ -1559,9 +1508,8 @@ numeric_power(PG_FUNCTION_ARGS)
global_rscale = MAX(global_rscale, res_dscale + 4);
global_rscale = MIN(global_rscale, NUMERIC_MAX_RESULT_SCALE);
- /* ----------
+ /*
* Call log_var() to compute and return the result
- * ----------
*/
power_var(&arg1, &arg2, &result);
@@ -1619,9 +1567,8 @@ numeric_int4(PG_FUNCTION_ARGS)
if (NUMERIC_IS_NAN(num))
elog(ERROR, "Cannot convert NaN to int4");
- /* ----------
+ /*
* Get the number in the variable format so we can round to integer.
- * ----------
*/
init_var(&x);
set_var_from_num(num, &x);
@@ -1670,9 +1617,8 @@ numeric_int8(PG_FUNCTION_ARGS)
if (NUMERIC_IS_NAN(num))
elog(ERROR, "Cannot convert NaN to int8");
- /* ----------
+ /*
* Get the number in the variable format so we can round to integer.
- * ----------
*/
init_var(&x);
set_var_from_num(num, &x);
@@ -1721,9 +1667,8 @@ numeric_int2(PG_FUNCTION_ARGS)
if (NUMERIC_IS_NAN(num))
elog(ERROR, "Cannot convert NaN to int2");
- /* ----------
+ /*
* Get the number in the variable format so we can round to integer.
- * ----------
*/
init_var(&x);
set_var_from_num(num, &x);
@@ -2512,10 +2457,8 @@ get_str_from_var(NumericVar *var, int dscale)
int i;
int d;
- /* ----------
- * Check if we must round up before printing the value and
- * do so.
- * ----------
+ /*
+ * Check if we must round up before printing the value and do so.
*/
i = dscale + var->weight + 1;
if (i >= 0 && var->ndigits > i)
@@ -2543,23 +2486,20 @@ get_str_from_var(NumericVar *var, int dscale)
else
var->ndigits = MAX(0, MIN(i, var->ndigits));
- /* ----------
+ /*
* Allocate space for the result
- * ----------
*/
str = palloc(MAX(0, dscale) + MAX(0, var->weight) + 4);
cp = str;
- /* ----------
+ /*
* Output a dash for negative values
- * ----------
*/
if (var->sign == NUMERIC_NEG)
*cp++ = '-';
- /* ----------
+ /*
* Output all digits before the decimal point
- * ----------
*/
i = MAX(var->weight, 0);
d = 0;
@@ -2573,10 +2513,9 @@ get_str_from_var(NumericVar *var, int dscale)
i--;
}
- /* ----------
- * If requested, output a decimal point and all the digits
- * that follow it.
- * ----------
+ /*
+ * If requested, output a decimal point and all the digits that follow
+ * it.
*/
if (dscale > 0)
{
@@ -2591,9 +2530,8 @@ get_str_from_var(NumericVar *var, int dscale)
}
}
- /* ----------
+ /*
* terminate the string and return it
- * ----------
*/
*cp = '\0';
return str;
@@ -2725,14 +2663,12 @@ apply_typmod(NumericVar *var, int32 typmod)
else
var->ndigits = MAX(0, MIN(i, var->ndigits));
- /* ----------
- * Check for overflow - note we can't do this before rounding,
- * because rounding could raise the weight. Also note that the
- * var's weight could be inflated by leading zeroes, which will
- * be stripped before storage but perhaps might not have been yet.
- * In any case, we must recognize a true zero, whose weight doesn't
- * mean anything.
- * ----------
+ /*
+ * Check for overflow - note we can't do this before rounding, because
+ * rounding could raise the weight. Also note that the var's weight
+ * could be inflated by leading zeroes, which will be stripped before
+ * storage but perhaps might not have been yet. In any case, we must
+ * recognize a true zero, whose weight doesn't mean anything.
*/
if (var->weight >= maxweight)
{
@@ -2805,28 +2741,27 @@ cmp_var(NumericVar *var1, NumericVar *var2)
static void
add_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
{
- /* ----------
+
+ /*
* Decide on the signs of the two variables what to do
- * ----------
*/
if (var1->sign == NUMERIC_POS)
{
if (var2->sign == NUMERIC_POS)
{
- /* ----------
- * Both are positive
- * result = +(ABS(var1) + ABS(var2))
- * ----------
+
+ /*
+ * Both are positive result = +(ABS(var1) + ABS(var2))
*/
add_abs(var1, var2, result);
result->sign = NUMERIC_POS;
}
else
{
- /* ----------
- * var1 is positive, var2 is negative
- * Must compare absolute values
- * ----------
+
+ /*
+ * var1 is positive, var2 is negative Must compare absolute
+ * values
*/
switch (cmp_abs(var1, var2))
{
@@ -2930,9 +2865,9 @@ add_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
static void
sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
{
- /* ----------
+
+ /*
* Decide on the signs of the two variables what to do
- * ----------
*/
if (var1->sign == NUMERIC_POS)
{
@@ -3157,17 +3092,15 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
int first_nextdigit;
int stat = 0;
- /* ----------
+ /*
* First of all division by zero check
- * ----------
*/
ndigits_tmp = var2->ndigits + 1;
if (ndigits_tmp == 1)
elog(ERROR, "division by zero on numeric");
- /* ----------
+ /*
* Determine the result sign, weight and number of digits to calculate
- * ----------
*/
if (var1->sign == var2->sign)
res_sign = NUMERIC_POS;
@@ -3178,9 +3111,8 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
if (res_ndigits <= 0)
res_ndigits = 1;
- /* ----------
+ /*
* Now result zero check
- * ----------
*/
if (var1->ndigits == 0)
{
@@ -3189,17 +3121,15 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
return;
}
- /* ----------
+ /*
* Initialize local variables
- * ----------
*/
init_var(&dividend);
for (i = 1; i < 10; i++)
init_var(&divisor[i]);
- /* ----------
+ /*
* Make a copy of the divisor which has one leading zero digit
- * ----------
*/
divisor[1].ndigits = ndigits_tmp;
divisor[1].rscale = var2->ndigits;
@@ -3209,9 +3139,8 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
divisor[1].digits[0] = 0;
memcpy(&(divisor[1].digits[1]), var2->digits, ndigits_tmp - 1);
- /* ----------
+ /*
* Make a copy of the dividend
- * ----------
*/
dividend.ndigits = var1->ndigits;
dividend.weight = 0;
@@ -3221,9 +3150,8 @@ div_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
dividend.digits = dividend.buf;
memcpy(dividend.digits, var1->digits, var1->ndigits);
- /* ----------
+ /*
* Setup the result
- * ----------
*/
digitbuf_free(result->buf);
result->buf = digitbuf_alloc(res_ndigits + 2);
@@ -3356,7 +3284,7 @@ mod_var(NumericVar *var1, NumericVar *var2, NumericVar *result)
init_var(&tmp);
- /* ----------
+ /* ---------
* We do this using the equation
* mod(x,y) = x - trunc(x/y)*y
* We fiddle a bit with global_rscale to control result precision.
@@ -3470,9 +3398,8 @@ sqrt_var(NumericVar *arg, NumericVar *result)
set_var_from_var(arg, &tmp_arg);
set_var_from_var(result, &last_val);
- /* ----------
+ /*
* Initialize the result to the first guess
- * ----------
*/
digitbuf_free(result->buf);
result->buf = digitbuf_alloc(1);
diff --git a/src/backend/utils/adt/pg_lzcompress.c b/src/backend/utils/adt/pg_lzcompress.c
index f548775ad2f..d92d969d40e 100644
--- a/src/backend/utils/adt/pg_lzcompress.c
+++ b/src/backend/utils/adt/pg_lzcompress.c
@@ -1,7 +1,7 @@
/* ----------
* pg_lzcompress.c -
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.10 2001/03/22 03:59:52 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.11 2001/03/22 06:16:17 momjian Exp $
*
* This is an implementation of LZ compression for PostgreSQL.
* It uses a simple history table and generates 2-3 byte tags
@@ -383,36 +383,33 @@ pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end,
char *ip;
char *hp;
- /* ----------
- * Traverse the linked history list until a good enough
- * match is found.
- * ----------
+ /*
+ * Traverse the linked history list until a good enough match is
+ * found.
*/
hent = hstart[pglz_hist_idx(input, end)];
while (hent && len < good_match)
{
- /* ----------
+
+ /*
* Be happy with lesser good matches the more entries we visited.
- * ----------
*/
good_match -= (good_match * good_drop) / 100;
- /* ----------
+ /*
* Stop if the offset does not fit into our tag anymore.
- * ----------
*/
thisoff = (ip = input) - (hp = hent->pos);
if (thisoff >= 0x0fff)
break;
- /* ----------
+ /*
* Determine length of match. A better match must be larger than
* the best so far. And if we already have a match of 16 or more
- * bytes, it's worth the call overhead to use memcmp() to check
- * if this match is equal for the same size. After that we must
+ * bytes, it's worth the call overhead to use memcmp() to check if
+ * this match is equal for the same size. After that we must
* fallback to character by character comparision to know the
* exact position where the diff occured.
- * ----------
*/
if (len >= 16)
{
@@ -434,9 +431,8 @@ pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end,
hp++;
}
- /* ----------
+ /*
* Remember this match as the best (if it is)
- * ----------
*/
if (thislen > len)
{
@@ -444,17 +440,15 @@ pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end,
off = thisoff;
}
- /* ----------
+ /*
* Advance to the next history entry
- * ----------
*/
hent = hent->next;
}
- /* ----------
- * Return match information only if it results at least in one
- * byte reduction.
- * ----------
+ /*
+ * Return match information only if it results at least in one byte
+ * reduction.
*/
if (len > 2)
{
@@ -495,23 +489,20 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate
int32 result_max;
int32 need_rate;
- /* ----------
+ /*
* Our fallback strategy is the default.
- * ----------
*/
if (strategy == NULL)
strategy = PGLZ_strategy_default;
- /* ----------
+ /*
* Save the original source size in the header.
- * ----------
*/
dest->rawsize = slen;
- /* ----------
+ /*
* If the strategy forbids compression (at all or if source chunk too
* small), copy input to output without compression.
- * ----------
*/
if (strategy->match_size_good == 0)
{
@@ -527,9 +518,8 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate
}
}
- /* ----------
+ /*
* Limit the match size to the maximum implementation allowed value
- * ----------
*/
if ((good_match = strategy->match_size_good) > PGLZ_MAX_MATCH)
good_match = PGLZ_MAX_MATCH;
@@ -541,22 +531,19 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate
if (good_drop > 100)
good_drop = 100;
- /* ----------
+ /*
* Initialize the history tables. For inputs smaller than
- * PGLZ_HISTORY_SIZE, we already have a big enough history
- * table on the stack frame.
- * ----------
+ * PGLZ_HISTORY_SIZE, we already have a big enough history table on
+ * the stack frame.
*/
memset((void *) hist_start, 0, sizeof(hist_start));
memset((void *) hist_entries, 0, sizeof(hist_entries));
- /* ----------
- * Compute the maximum result size allowed by the strategy.
- * If the input size exceeds force_input_size, the max result size
- * is the input size itself.
- * Otherwise, it is the input size minus the minimum wanted
- * compression rate.
- * ----------
+ /*
+ * Compute the maximum result size allowed by the strategy. If the
+ * input size exceeds force_input_size, the max result size is the
+ * input size itself. Otherwise, it is the input size minus the
+ * minimum wanted compression rate.
*/
if (slen >= strategy->force_input_size)
result_max = slen;
@@ -570,16 +557,15 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate
result_max = slen - ((slen * need_rate) / 100);
}
- /* ----------
+ /*
* Compress the source directly into the output buffer.
- * ----------
*/
while (dp < dend)
{
- /* ----------
- * If we already exceeded the maximum result size, set no compression
- * flag and stop this. But don't check too often.
- * ----------
+
+ /*
+ * If we already exceeded the maximum result size, set no
+ * compression flag and stop this. But don't check too often.
*/
if (bp - bstart >= result_max)
{
@@ -587,17 +573,16 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate
break;
}
- /* ----------
+ /*
* Try to find a match in the history
- * ----------
*/
if (pglz_find_match(hist_start, dp, dend, &match_len,
&match_off, good_match, good_drop))
{
- /* ----------
- * Create the tag and add history entries for
- * all matched characters.
- * ----------
+
+ /*
+ * Create the tag and add history entries for all matched
+ * characters.
*/
pglz_out_tag(ctrlp, ctrlb, ctrl, bp, match_len, match_off);
while (match_len--)
@@ -609,9 +594,9 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate
}
else
{
- /* ----------
+
+ /*
* No match found. Copy one literal byte.
- * ----------
*/
pglz_out_literal(ctrlp, ctrlb, ctrl, bp, *dp);
pglz_hist_add(hist_start, hist_entries, hist_next, dp, dend);
@@ -620,11 +605,10 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate
}
}
- /* ----------
- * If we are still in compressing mode, write out the last
- * control byte and determine if the compression gained the
- * rate requested by the strategy.
- * ----------
+ /*
+ * If we are still in compressing mode, write out the last control
+ * byte and determine if the compression gained the rate requested by
+ * the strategy.
*/
if (do_compress)
{
@@ -635,12 +619,10 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate
do_compress = 0;
}
- /* ----------
- * Done - if we successfully compressed and matched the
- * strategy's constraints, return the compressed result.
- * Otherwise copy the original source over it and return
- * the original length.
- * ----------
+ /*
+ * Done - if we successfully compressed and matched the strategy's
+ * constraints, return the compressed result. Otherwise copy the
+ * original source over it and return the original length.
*/
if (do_compress)
{
@@ -685,22 +667,22 @@ pglz_decompress(PGLZ_Header *source, char *dest)
while (dp < dend)
{
- /* ----------
+
+ /*
* Read one control byte and process the next 8 items.
- * ----------
*/
ctrl = *dp++;
for (ctrlc = 0; ctrlc < 8 && dp < dend; ctrlc++)
{
if (ctrl & 1)
{
- /* ----------
- * Otherwise it contains the match length minus 3
- * and the upper 4 bits of the offset. The next following
- * byte contains the lower 8 bits of the offset. If
- * the length is coded as 18, another extension tag byte
- * tells how much longer the match really was (0-255).
- * ----------
+
+ /*
+ * Otherwise it contains the match length minus 3 and the
+ * upper 4 bits of the offset. The next following byte
+ * contains the lower 8 bits of the offset. If the length
+ * is coded as 18, another extension tag byte tells how
+ * much longer the match really was (0-255).
*/
len = (dp[0] & 0x0f) + 3;
off = ((dp[0] & 0xf0) << 4) | dp[1];
@@ -708,12 +690,11 @@ pglz_decompress(PGLZ_Header *source, char *dest)
if (len == 18)
len += *dp++;
- /* ----------
- * Now we copy the bytes specified by the tag from
- * OUTPUT to OUTPUT. It is dangerous and platform
- * dependant to use memcpy() here, because the copied
- * areas could overlap extremely!
- * ----------
+ /*
+ * Now we copy the bytes specified by the tag from OUTPUT
+ * to OUTPUT. It is dangerous and platform dependant to
+ * use memcpy() here, because the copied areas could
+ * overlap extremely!
*/
while (len--)
{
@@ -723,25 +704,23 @@ pglz_decompress(PGLZ_Header *source, char *dest)
}
else
{
- /* ----------
- * An unset control bit means LITERAL BYTE. So we
- * just copy one from INPUT to OUTPUT.
- * ----------
+
+ /*
+ * An unset control bit means LITERAL BYTE. So we just
+ * copy one from INPUT to OUTPUT.
*/
*bp++ = *dp++;
}
- /* ----------
+ /*
* Advance the control bit
- * ----------
*/
ctrl >>= 1;
}
}
- /* ----------
+ /*
* That's it.
- * ----------
*/
return (char *) bp - dest;
}
@@ -761,11 +740,10 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
if (dstate->tocopy > 0)
{
- /* ----------
- * Copy one byte from output to output until we did it
- * for the length specified by the last tag. Return that
- * byte.
- * ----------
+
+ /*
+ * Copy one byte from output to output until we did it for the
+ * length specified by the last tag. Return that byte.
*/
dstate->tocopy--;
return (*(dstate->cp_out++) = *(dstate->cp_copy++));
@@ -773,25 +751,24 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
if (dstate->ctrl_count == 0)
{
- /* ----------
- * Get the next control byte if we need to, but check
- * for EOF before.
- * ----------
+
+ /*
+ * Get the next control byte if we need to, but check for EOF
+ * before.
*/
if (dstate->cp_in == dstate->cp_end)
return EOF;
- /* ----------
- * This decompression method saves time only, if we stop near
- * the beginning of the data (maybe because we're called by a
+ /*
+ * This decompression method saves time only, if we stop near the
+ * beginning of the data (maybe because we're called by a
* comparision function and a difference occurs early). Otherwise,
* all the checks, needed here, cause too much overhead.
*
* Thus we decompress the entire rest at once into the temporary
- * buffer and change the decomp state to return the prepared
- * data from the buffer by the more simple calls to
+ * buffer and change the decomp state to return the prepared data
+ * from the buffer by the more simple calls to
* pglz_get_next_decomp_char_from_plain().
- * ----------
*/
if (dstate->cp_out - dstate->temp_buf >= 256)
{
@@ -838,32 +815,29 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
return (int) (*(dstate->cp_in++));
}
- /* ----------
+ /*
* Not yet, get next control byte into decomp state.
- * ----------
*/
dstate->ctrl = (unsigned char) (*(dstate->cp_in++));
dstate->ctrl_count = 8;
}
- /* ----------
+ /*
* Check for EOF in tag/literal byte data.
- * ----------
*/
if (dstate->cp_in == dstate->cp_end)
return EOF;
- /* ----------
+ /*
* Handle next control bit.
- * ----------
*/
dstate->ctrl_count--;
if (dstate->ctrl & 0x01)
{
- /* ----------
- * Bit is set, so tag is following. Setup copy information
- * and do the copy for the first byte as above.
- * ----------
+
+ /*
+ * Bit is set, so tag is following. Setup copy information and do
+ * the copy for the first byte as above.
*/
int off;
@@ -879,9 +853,9 @@ pglz_get_next_decomp_char_from_lzdata(PGLZ_DecompState *dstate)
}
else
{
- /* ----------
+
+ /*
* Bit is unset, so literal byte follows.
- * ----------
*/
retval = (int) (*(dstate->cp_out++) = *(dstate->cp_in++));
}
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index db7f67ec601..6294eb086cf 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -18,7 +18,7 @@
* Portions Copyright (c) 2000-2001, PostgreSQL Global Development Group
* Copyright 1999 Jan Wieck
*
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.22 2001/03/22 03:59:53 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.23 2001/03/22 06:16:17 momjian Exp $
*
* ----------
*/
@@ -177,9 +177,9 @@ RI_FKey_check(PG_FUNCTION_ARGS)
ReferentialIntegritySnapshotOverride = true;
- /* ----------
- * Check that this is a valid trigger call on the right time and event.
- * ----------
+ /*
+ * Check that this is a valid trigger call on the right time and
+ * event.
*/
if (!CALLED_AS_TRIGGER(fcinfo))
elog(ERROR, "RI_FKey_check() not fired by trigger manager");
@@ -190,9 +190,8 @@ RI_FKey_check(PG_FUNCTION_ARGS)
!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
elog(ERROR, "RI_FKey_check() must be fired for INSERT or UPDATE");
- /* ----------
+ /*
* Check for the correct # of call arguments
- * ----------
*/
tgnargs = trigdata->tg_trigger->tgnargs;
tgargs = trigdata->tg_trigger->tgargs;
@@ -202,10 +201,9 @@ RI_FKey_check(PG_FUNCTION_ARGS)
elog(ERROR, "too many keys (%d max) in call to RI_FKey_check()",
RI_MAX_NUMKEYS);
- /* ----------
- * Get the relation descriptors of the FK and PK tables and
- * the new tuple.
- * ----------
+ /*
+ * Get the relation descriptors of the FK and PK tables and the new
+ * tuple.
*/
fk_rel = trigdata->tg_relation;
pk_rel = heap_openr(tgargs[RI_PK_RELNAME_ARGNO], NoLock);
@@ -242,7 +240,7 @@ RI_FKey_check(PG_FUNCTION_ARGS)
{
char querystr[8192];
- /* ----------
+ /* ---------
* The query string built is
* SELECT oid FROM ONLY <pktable>
* ----------
@@ -251,18 +249,16 @@ RI_FKey_check(PG_FUNCTION_ARGS)
tgargs[RI_PK_RELNAME_ARGNO],
tgargs[RI_PK_RELNAME_ARGNO]);
- /* ----------
+ /*
* Prepare, save and remember the new plan.
- * ----------
*/
qplan = SPI_prepare(querystr, 0, NULL);
qplan = SPI_saveplan(qplan);
ri_HashPreparedPlan(&qkey, qplan);
}
- /* ----------
+ /*
* Execute the plan
- * ----------
*/
if (SPI_connect() != SPI_OK_CONNECT)
elog(NOTICE, "SPI_connect() failed in RI_FKey_check()");
@@ -304,30 +300,30 @@ RI_FKey_check(PG_FUNCTION_ARGS)
switch (ri_NullCheck(fk_rel, new_row, &qkey, RI_KEYPAIR_FK_IDX))
{
case RI_KEYS_ALL_NULL:
- /* ----------
- * No check - if NULLs are allowed at all is
- * already checked by NOT NULL constraint.
+
+ /*
+ * No check - if NULLs are allowed at all is already checked
+ * by NOT NULL constraint.
*
- * This is true for MATCH FULL, MATCH PARTIAL, and
- * MATCH <unspecified>
- * ----------
+ * This is true for MATCH FULL, MATCH PARTIAL, and MATCH
+ * <unspecified>
*/
heap_close(pk_rel, NoLock);
return PointerGetDatum(NULL);
case RI_KEYS_SOME_NULL:
- /* ----------
- * This is the only case that differs between the
- * three kinds of MATCH.
- * ----------
+
+ /*
+ * This is the only case that differs between the three kinds
+ * of MATCH.
*/
switch (match_type)
{
case RI_MATCH_TYPE_FULL:
- /* ----------
- * Not allowed - MATCH FULL says either all or none
- * of the attributes can be NULLs
- * ----------
+
+ /*
+ * Not allowed - MATCH FULL says either all or none of
+ * the attributes can be NULLs
*/
elog(ERROR, "%s referential integrity violation - "
"MATCH FULL doesn't allow mixing of NULL "
@@ -337,21 +333,21 @@ RI_FKey_check(PG_FUNCTION_ARGS)
return PointerGetDatum(NULL);
case RI_MATCH_TYPE_UNSPECIFIED:
- /* ----------
+
+ /*
* MATCH <unspecified> - if ANY column is null, we
* have a match.
- * ----------
*/
heap_close(pk_rel, NoLock);
return PointerGetDatum(NULL);
case RI_MATCH_TYPE_PARTIAL:
- /* ----------
+
+ /*
* MATCH PARTIAL - all non-null columns must match.
- * (not implemented, can be done by modifying the query
- * below to only include non-null columns, or by
+ * (not implemented, can be done by modifying the
+ * query below to only include non-null columns, or by
* writing a special version here)
- * ----------
*/
elog(ERROR, "MATCH PARTIAL not yet implemented");
heap_close(pk_rel, NoLock);
@@ -359,30 +355,27 @@ RI_FKey_check(PG_FUNCTION_ARGS)
}
case RI_KEYS_NONE_NULL:
- /* ----------
+
+ /*
* Have a full qualified key - continue below for all three
* kinds of MATCH.
- * ----------
*/
break;
}
- /* ----------
- * Note:
- * We cannot avoid the check on UPDATE, even if old and new
- * key are the same. Otherwise, someone could DELETE the PK
- * that consists of the DEFAULT values, and if there are any
- * references, a ON DELETE SET DEFAULT action would update
- * the references to exactly these values but we wouldn't see
- * that weired case (this is the only place to see it).
- * ----------
+ /*
+ * Note: We cannot avoid the check on UPDATE, even if old and new key
+ * are the same. Otherwise, someone could DELETE the PK that consists
+ * of the DEFAULT values, and if there are any references, a ON DELETE
+ * SET DEFAULT action would update the references to exactly these
+ * values but we wouldn't see that weired case (this is the only place
+ * to see it).
*/
if (SPI_connect() != SPI_OK_CONNECT)
elog(NOTICE, "SPI_connect() failed in RI_FKey_check()");
- /* ----------
+ /*
* Fetch or prepare a saved plan for the real check
- * ----------
*/
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
@@ -416,28 +409,26 @@ RI_FKey_check(PG_FUNCTION_ARGS)
tgargs[RI_PK_RELNAME_ARGNO]);
strcat(querystr, buf);
- /* ----------
+ /*
* Prepare, save and remember the new plan.
- * ----------
*/
qplan = SPI_prepare(querystr, qkey.nkeypairs, queryoids);
qplan = SPI_saveplan(qplan);
ri_HashPreparedPlan(&qkey, qplan);
}
- /* ----------
- * We have a plan now. Build up the arguments for SPI_execp()
- * from the key values in the new FK tuple.
- * ----------
+ /*
+ * We have a plan now. Build up the arguments for SPI_execp() from the
+ * key values in the new FK tuple.
*/
for (i = 0; i < qkey.nkeypairs; i++)
{
- /* ----------
+
+ /*
* We can implement MATCH PARTIAL by excluding this column from
* the query if it is null. Simple! Unfortunately, the
- * referential actions aren't so I've not bothered to do so
- * for the moment.
- * ----------
+ * referential actions aren't so I've not bothered to do so for
+ * the moment.
*/
check_values[i] = SPI_getbinval(new_row,
@@ -451,9 +442,8 @@ RI_FKey_check(PG_FUNCTION_ARGS)
}
check_nulls[i] = '\0';
- /* ----------
+ /*
* Now check that foreign key exists in PK table
- * ----------
*/
SetUserId(RelationGetForm(pk_rel)->relowner);
@@ -477,9 +467,8 @@ RI_FKey_check(PG_FUNCTION_ARGS)
return PointerGetDatum(NULL);
- /* ----------
+ /*
* Never reached
- * ----------
*/
elog(ERROR, "internal error #1 in ri_triggers.c");
return PointerGetDatum(NULL);
@@ -541,9 +530,9 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
ReferentialIntegritySnapshotOverride = true;
- /* ----------
- * Check that this is a valid trigger call on the right time and event.
- * ----------
+ /*
+ * Check that this is a valid trigger call on the right time and
+ * event.
*/
if (!CALLED_AS_TRIGGER(fcinfo))
elog(ERROR, "RI_FKey_noaction_del() not fired by trigger manager");
@@ -553,9 +542,8 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
if (!TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
elog(ERROR, "RI_FKey_noaction_del() must be fired for DELETE");
- /* ----------
+ /*
* Check for the correct # of call arguments
- * ----------
*/
tgnargs = trigdata->tg_trigger->tgnargs;
tgargs = trigdata->tg_trigger->tgargs;
@@ -565,17 +553,15 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
elog(ERROR, "too many keys (%d max) in call to RI_FKey_noaction_del()",
RI_MAX_NUMKEYS);
- /* ----------
+ /*
* Nothing to do if no column names to compare given
- * ----------
*/
if (tgnargs == 4)
return PointerGetDatum(NULL);
- /* ----------
- * Get the relation descriptors of the FK and PK tables and
- * the old tuple.
- * ----------
+ /*
+ * Get the relation descriptors of the FK and PK tables and the old
+ * tuple.
*/
fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
pk_rel = trigdata->tg_relation;
@@ -601,18 +587,18 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
{
case RI_KEYS_ALL_NULL:
case RI_KEYS_SOME_NULL:
- /* ----------
+
+ /*
* No check - MATCH FULL means there cannot be any
* reference to old key if it contains NULL
- * ----------
*/
heap_close(fk_rel, NoLock);
return PointerGetDatum(NULL);
case RI_KEYS_NONE_NULL:
- /* ----------
+
+ /*
* Have a full qualified key - continue below
- * ----------
*/
break;
}
@@ -621,10 +607,9 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
if (SPI_connect() != SPI_OK_CONNECT)
elog(NOTICE, "SPI_connect() failed in RI_FKey_noaction_del()");
- /* ----------
+ /*
* Fetch or prepare a saved plan for the restrict delete
* lookup if foreign references exist
- * ----------
*/
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
@@ -658,19 +643,17 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
tgargs[RI_FK_RELNAME_ARGNO]);
strcat(querystr, buf);
- /* ----------
+ /*
* Prepare, save and remember the new plan.
- * ----------
*/
qplan = SPI_prepare(querystr, qkey.nkeypairs, queryoids);
qplan = SPI_saveplan(qplan);
ri_HashPreparedPlan(&qkey, qplan);
}
- /* ----------
+ /*
* We have a plan now. Build up the arguments for SPI_execp()
* from the key values in the deleted PK tuple.
- * ----------
*/
for (i = 0; i < qkey.nkeypairs; i++)
{
@@ -685,9 +668,8 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
}
del_nulls[i] = '\0';
- /* ----------
+ /*
* Now check for existing references
- * ----------
*/
SetUserId(RelationGetForm(pk_rel)->relowner);
@@ -708,18 +690,16 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS)
return PointerGetDatum(NULL);
- /* ----------
+ /*
* Handle MATCH PARTIAL restrict delete.
- * ----------
*/
case RI_MATCH_TYPE_PARTIAL:
elog(ERROR, "MATCH PARTIAL not yet supported");
return PointerGetDatum(NULL);
}
- /* ----------
+ /*
* Never reached
- * ----------
*/
elog(ERROR, "internal error #2 in ri_triggers.c");
return PointerGetDatum(NULL);
@@ -756,9 +736,9 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
ReferentialIntegritySnapshotOverride = true;
- /* ----------
- * Check that this is a valid trigger call on the right time and event.
- * ----------
+ /*
+ * Check that this is a valid trigger call on the right time and
+ * event.
*/
if (!CALLED_AS_TRIGGER(fcinfo))
elog(ERROR, "RI_FKey_noaction_upd() not fired by trigger manager");
@@ -768,9 +748,8 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
elog(ERROR, "RI_FKey_noaction_upd() must be fired for UPDATE");
- /* ----------
+ /*
* Check for the correct # of call arguments
- * ----------
*/
tgnargs = trigdata->tg_trigger->tgnargs;
tgargs = trigdata->tg_trigger->tgargs;
@@ -780,17 +759,15 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
elog(ERROR, "too many keys (%d max) in call to RI_FKey_noaction_upd()",
RI_MAX_NUMKEYS);
- /* ----------
+ /*
* Nothing to do if no column names to compare given
- * ----------
*/
if (tgnargs == 4)
return PointerGetDatum(NULL);
- /* ----------
- * Get the relation descriptors of the FK and PK tables and
- * the new and old tuple.
- * ----------
+ /*
+ * Get the relation descriptors of the FK and PK tables and the new
+ * and old tuple.
*/
fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
pk_rel = trigdata->tg_relation;
@@ -817,26 +794,25 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
{
case RI_KEYS_ALL_NULL:
case RI_KEYS_SOME_NULL:
- /* ----------
+
+ /*
* No check - MATCH FULL means there cannot be any
* reference to old key if it contains NULL
- * ----------
*/
heap_close(fk_rel, NoLock);
return PointerGetDatum(NULL);
case RI_KEYS_NONE_NULL:
- /* ----------
+
+ /*
* Have a full qualified key - continue below
- * ----------
*/
break;
}
heap_close(fk_rel, NoLock);
- /* ----------
+ /*
* No need to check anything if old and new keys are equal
- * ----------
*/
if (ri_KeysEqual(pk_rel, old_row, new_row, &qkey,
RI_KEYPAIR_PK_IDX))
@@ -845,10 +821,9 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
if (SPI_connect() != SPI_OK_CONNECT)
elog(NOTICE, "SPI_connect() failed in RI_FKey_noaction_upd()");
- /* ----------
+ /*
* Fetch or prepare a saved plan for the noaction update
* lookup if foreign references exist
- * ----------
*/
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
@@ -882,19 +857,17 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
tgargs[RI_FK_RELNAME_ARGNO]);
strcat(querystr, buf);
- /* ----------
+ /*
* Prepare, save and remember the new plan.
- * ----------
*/
qplan = SPI_prepare(querystr, qkey.nkeypairs, queryoids);
qplan = SPI_saveplan(qplan);
ri_HashPreparedPlan(&qkey, qplan);
}
- /* ----------
+ /*
* We have a plan now. Build up the arguments for SPI_execp()
* from the key values in the updated PK tuple.
- * ----------
*/
for (i = 0; i < qkey.nkeypairs; i++)
{
@@ -909,9 +882,8 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
}
upd_nulls[i] = '\0';
- /* ----------
+ /*
* Now check for existing references
- * ----------
*/
SetUserId(RelationGetForm(pk_rel)->relowner);
@@ -932,18 +904,16 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS)
return PointerGetDatum(NULL);
- /* ----------
+ /*
* Handle MATCH PARTIAL noaction update.
- * ----------
*/
case RI_MATCH_TYPE_PARTIAL:
elog(ERROR, "MATCH PARTIAL not yet supported");
return PointerGetDatum(NULL);
}
- /* ----------
+ /*
* Never reached
- * ----------
*/
elog(ERROR, "internal error #3 in ri_triggers.c");
return PointerGetDatum(NULL);
@@ -974,9 +944,9 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
ReferentialIntegritySnapshotOverride = true;
- /* ----------
- * Check that this is a valid trigger call on the right time and event.
- * ----------
+ /*
+ * Check that this is a valid trigger call on the right time and
+ * event.
*/
if (!CALLED_AS_TRIGGER(fcinfo))
elog(ERROR, "RI_FKey_cascade_del() not fired by trigger manager");
@@ -986,9 +956,8 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
if (!TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
elog(ERROR, "RI_FKey_cascade_del() must be fired for DELETE");
- /* ----------
+ /*
* Check for the correct # of call arguments
- * ----------
*/
tgnargs = trigdata->tg_trigger->tgnargs;
tgargs = trigdata->tg_trigger->tgargs;
@@ -998,17 +967,15 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
elog(ERROR, "too many keys (%d max) in call to RI_FKey_cascade_del()",
RI_MAX_NUMKEYS);
- /* ----------
+ /*
* Nothing to do if no column names to compare given
- * ----------
*/
if (tgnargs == 4)
return PointerGetDatum(NULL);
- /* ----------
- * Get the relation descriptors of the FK and PK tables and
- * the old tuple.
- * ----------
+ /*
+ * Get the relation descriptors of the FK and PK tables and the old
+ * tuple.
*/
fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
pk_rel = trigdata->tg_relation;
@@ -1034,18 +1001,18 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
{
case RI_KEYS_ALL_NULL:
case RI_KEYS_SOME_NULL:
- /* ----------
+
+ /*
* No check - MATCH FULL means there cannot be any
* reference to old key if it contains NULL
- * ----------
*/
heap_close(fk_rel, NoLock);
return PointerGetDatum(NULL);
case RI_KEYS_NONE_NULL:
- /* ----------
+
+ /*
* Have a full qualified key - continue below
- * ----------
*/
break;
}
@@ -1054,9 +1021,8 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
if (SPI_connect() != SPI_OK_CONNECT)
elog(NOTICE, "SPI_connect() failed in RI_FKey_cascade_del()");
- /* ----------
+ /*
* Fetch or prepare a saved plan for the cascaded delete
- * ----------
*/
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
@@ -1087,19 +1053,17 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
qkey.keypair[i][RI_KEYPAIR_PK_IDX]);
}
- /* ----------
+ /*
* Prepare, save and remember the new plan.
- * ----------
*/
qplan = SPI_prepare(querystr, qkey.nkeypairs, queryoids);
qplan = SPI_saveplan(qplan);
ri_HashPreparedPlan(&qkey, qplan);
}
- /* ----------
+ /*
* We have a plan now. Build up the arguments for SPI_execp()
* from the key values in the deleted PK tuple.
- * ----------
*/
for (i = 0; i < qkey.nkeypairs; i++)
{
@@ -1114,9 +1078,8 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
}
del_nulls[i] = '\0';
- /* ----------
+ /*
* Now delete constraint
- * ----------
*/
if (SPI_execp(qplan, del_values, del_nulls, 0) != SPI_OK_DELETE)
elog(ERROR, "SPI_execp() failed in RI_FKey_cascade_del()");
@@ -1126,18 +1089,16 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS)
return PointerGetDatum(NULL);
- /* ----------
+ /*
* Handle MATCH PARTIAL cascaded delete.
- * ----------
*/
case RI_MATCH_TYPE_PARTIAL:
elog(ERROR, "MATCH PARTIAL not yet supported");
return PointerGetDatum(NULL);
}
- /* ----------
+ /*
* Never reached
- * ----------
*/
elog(ERROR, "internal error #4 in ri_triggers.c");
return PointerGetDatum(NULL);
@@ -1170,9 +1131,9 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
ReferentialIntegritySnapshotOverride = true;
- /* ----------
- * Check that this is a valid trigger call on the right time and event.
- * ----------
+ /*
+ * Check that this is a valid trigger call on the right time and
+ * event.
*/
if (!CALLED_AS_TRIGGER(fcinfo))
elog(ERROR, "RI_FKey_cascade_upd() not fired by trigger manager");
@@ -1182,9 +1143,8 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
elog(ERROR, "RI_FKey_cascade_upd() must be fired for UPDATE");
- /* ----------
+ /*
* Check for the correct # of call arguments
- * ----------
*/
tgnargs = trigdata->tg_trigger->tgnargs;
tgargs = trigdata->tg_trigger->tgargs;
@@ -1194,17 +1154,15 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
elog(ERROR, "too many keys (%d max) in call to RI_FKey_cascade_upd()",
RI_MAX_NUMKEYS);
- /* ----------
+ /*
* Nothing to do if no column names to compare given
- * ----------
*/
if (tgnargs == 4)
return PointerGetDatum(NULL);
- /* ----------
- * Get the relation descriptors of the FK and PK tables and
- * the new and old tuple.
- * ----------
+ /*
+ * Get the relation descriptors of the FK and PK tables and the new
+ * and old tuple.
*/
fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
pk_rel = trigdata->tg_relation;
@@ -1231,26 +1189,25 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
{
case RI_KEYS_ALL_NULL:
case RI_KEYS_SOME_NULL:
- /* ----------
+
+ /*
* No update - MATCH FULL means there cannot be any
* reference to old key if it contains NULL
- * ----------
*/
heap_close(fk_rel, NoLock);
return PointerGetDatum(NULL);
case RI_KEYS_NONE_NULL:
- /* ----------
+
+ /*
* Have a full qualified key - continue below
- * ----------
*/
break;
}
heap_close(fk_rel, NoLock);
- /* ----------
+ /*
* No need to do anything if old and new keys are equal
- * ----------
*/
if (ri_KeysEqual(pk_rel, old_row, new_row, &qkey,
RI_KEYPAIR_PK_IDX))
@@ -1259,10 +1216,9 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
if (SPI_connect() != SPI_OK_CONNECT)
elog(NOTICE, "SPI_connect() failed in RI_FKey_cascade_upd()");
- /* ----------
- * Fetch or prepare a saved plan for the cascaded update
- * of foreign references
- * ----------
+ /*
+ * Fetch or prepare a saved plan for the cascaded update of
+ * foreign references
*/
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
@@ -1304,19 +1260,17 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
}
strcat(querystr, qualstr);
- /* ----------
+ /*
* Prepare, save and remember the new plan.
- * ----------
*/
qplan = SPI_prepare(querystr, qkey.nkeypairs * 2, queryoids);
qplan = SPI_saveplan(qplan);
ri_HashPreparedPlan(&qkey, qplan);
}
- /* ----------
+ /*
* We have a plan now. Build up the arguments for SPI_execp()
* from the key values in the updated PK tuple.
- * ----------
*/
for (i = 0, j = qkey.nkeypairs; i < qkey.nkeypairs; i++, j++)
{
@@ -1340,9 +1294,8 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
}
upd_nulls[j] = '\0';
- /* ----------
+ /*
* Now update the existing references
- * ----------
*/
if (SPI_execp(qplan, upd_values, upd_nulls, 0) != SPI_OK_UPDATE)
elog(ERROR, "SPI_execp() failed in RI_FKey_cascade_upd()");
@@ -1352,18 +1305,16 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS)
return PointerGetDatum(NULL);
- /* ----------
+ /*
* Handle MATCH PARTIAL cascade update.
- * ----------
*/
case RI_MATCH_TYPE_PARTIAL:
elog(ERROR, "MATCH PARTIAL not yet supported");
return PointerGetDatum(NULL);
}
- /* ----------
+ /*
* Never reached
- * ----------
*/
elog(ERROR, "internal error #5 in ri_triggers.c");
return PointerGetDatum(NULL);
@@ -1401,9 +1352,9 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
ReferentialIntegritySnapshotOverride = true;
- /* ----------
- * Check that this is a valid trigger call on the right time and event.
- * ----------
+ /*
+ * Check that this is a valid trigger call on the right time and
+ * event.
*/
if (!CALLED_AS_TRIGGER(fcinfo))
elog(ERROR, "RI_FKey_restrict_del() not fired by trigger manager");
@@ -1413,9 +1364,8 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
if (!TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
elog(ERROR, "RI_FKey_restrict_del() must be fired for DELETE");
- /* ----------
+ /*
* Check for the correct # of call arguments
- * ----------
*/
tgnargs = trigdata->tg_trigger->tgnargs;
tgargs = trigdata->tg_trigger->tgargs;
@@ -1425,17 +1375,15 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
elog(ERROR, "too many keys (%d max) in call to RI_FKey_restrict_del()",
RI_MAX_NUMKEYS);
- /* ----------
+ /*
* Nothing to do if no column names to compare given
- * ----------
*/
if (tgnargs == 4)
return PointerGetDatum(NULL);
- /* ----------
- * Get the relation descriptors of the FK and PK tables and
- * the old tuple.
- * ----------
+ /*
+ * Get the relation descriptors of the FK and PK tables and the old
+ * tuple.
*/
fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
pk_rel = trigdata->tg_relation;
@@ -1461,18 +1409,18 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
{
case RI_KEYS_ALL_NULL:
case RI_KEYS_SOME_NULL:
- /* ----------
+
+ /*
* No check - MATCH FULL means there cannot be any
* reference to old key if it contains NULL
- * ----------
*/
heap_close(fk_rel, NoLock);
return PointerGetDatum(NULL);
case RI_KEYS_NONE_NULL:
- /* ----------
+
+ /*
* Have a full qualified key - continue below
- * ----------
*/
break;
}
@@ -1481,10 +1429,9 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
if (SPI_connect() != SPI_OK_CONNECT)
elog(NOTICE, "SPI_connect() failed in RI_FKey_restrict_del()");
- /* ----------
+ /*
* Fetch or prepare a saved plan for the restrict delete
* lookup if foreign references exist
- * ----------
*/
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
@@ -1518,19 +1465,17 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
tgargs[RI_FK_RELNAME_ARGNO]);
strcat(querystr, buf);
- /* ----------
+ /*
* Prepare, save and remember the new plan.
- * ----------
*/
qplan = SPI_prepare(querystr, qkey.nkeypairs, queryoids);
qplan = SPI_saveplan(qplan);
ri_HashPreparedPlan(&qkey, qplan);
}
- /* ----------
+ /*
* We have a plan now. Build up the arguments for SPI_execp()
* from the key values in the deleted PK tuple.
- * ----------
*/
for (i = 0; i < qkey.nkeypairs; i++)
{
@@ -1545,9 +1490,8 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
}
del_nulls[i] = '\0';
- /* ----------
+ /*
* Now check for existing references
- * ----------
*/
if (SPI_execp(qplan, del_values, del_nulls, 1) != SPI_OK_SELECT)
elog(ERROR, "SPI_execp() failed in RI_FKey_restrict_del()");
@@ -1564,18 +1508,16 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS)
return PointerGetDatum(NULL);
- /* ----------
+ /*
* Handle MATCH PARTIAL restrict delete.
- * ----------
*/
case RI_MATCH_TYPE_PARTIAL:
elog(ERROR, "MATCH PARTIAL not yet supported");
return PointerGetDatum(NULL);
}
- /* ----------
+ /*
* Never reached
- * ----------
*/
elog(ERROR, "internal error #6 in ri_triggers.c");
return PointerGetDatum(NULL);
@@ -1617,9 +1559,9 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
ReferentialIntegritySnapshotOverride = true;
- /* ----------
- * Check that this is a valid trigger call on the right time and event.
- * ----------
+ /*
+ * Check that this is a valid trigger call on the right time and
+ * event.
*/
if (!CALLED_AS_TRIGGER(fcinfo))
elog(ERROR, "RI_FKey_restrict_upd() not fired by trigger manager");
@@ -1629,9 +1571,8 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
elog(ERROR, "RI_FKey_restrict_upd() must be fired for UPDATE");
- /* ----------
+ /*
* Check for the correct # of call arguments
- * ----------
*/
tgnargs = trigdata->tg_trigger->tgnargs;
tgargs = trigdata->tg_trigger->tgargs;
@@ -1641,17 +1582,15 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
elog(ERROR, "too many keys (%d max) in call to RI_FKey_restrict_upd()",
RI_MAX_NUMKEYS);
- /* ----------
+ /*
* Nothing to do if no column names to compare given
- * ----------
*/
if (tgnargs == 4)
return PointerGetDatum(NULL);
- /* ----------
- * Get the relation descriptors of the FK and PK tables and
- * the new and old tuple.
- * ----------
+ /*
+ * Get the relation descriptors of the FK and PK tables and the new
+ * and old tuple.
*/
fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
pk_rel = trigdata->tg_relation;
@@ -1678,26 +1617,25 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
{
case RI_KEYS_ALL_NULL:
case RI_KEYS_SOME_NULL:
- /* ----------
+
+ /*
* No check - MATCH FULL means there cannot be any
* reference to old key if it contains NULL
- * ----------
*/
heap_close(fk_rel, NoLock);
return PointerGetDatum(NULL);
case RI_KEYS_NONE_NULL:
- /* ----------
+
+ /*
* Have a full qualified key - continue below
- * ----------
*/
break;
}
heap_close(fk_rel, NoLock);
- /* ----------
+ /*
* No need to check anything if old and new keys are equal
- * ----------
*/
if (ri_KeysEqual(pk_rel, old_row, new_row, &qkey,
RI_KEYPAIR_PK_IDX))
@@ -1706,10 +1644,9 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
if (SPI_connect() != SPI_OK_CONNECT)
elog(NOTICE, "SPI_connect() failed in RI_FKey_restrict_upd()");
- /* ----------
+ /*
* Fetch or prepare a saved plan for the restrict update
* lookup if foreign references exist
- * ----------
*/
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
@@ -1743,19 +1680,17 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
tgargs[RI_FK_RELNAME_ARGNO]);
strcat(querystr, buf);
- /* ----------
+ /*
* Prepare, save and remember the new plan.
- * ----------
*/
qplan = SPI_prepare(querystr, qkey.nkeypairs, queryoids);
qplan = SPI_saveplan(qplan);
ri_HashPreparedPlan(&qkey, qplan);
}
- /* ----------
+ /*
* We have a plan now. Build up the arguments for SPI_execp()
* from the key values in the updated PK tuple.
- * ----------
*/
for (i = 0; i < qkey.nkeypairs; i++)
{
@@ -1770,9 +1705,8 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
}
upd_nulls[i] = '\0';
- /* ----------
+ /*
* Now check for existing references
- * ----------
*/
SetUserId(RelationGetForm(pk_rel)->relowner);
@@ -1793,18 +1727,16 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS)
return PointerGetDatum(NULL);
- /* ----------
+ /*
* Handle MATCH PARTIAL restrict update.
- * ----------
*/
case RI_MATCH_TYPE_PARTIAL:
elog(ERROR, "MATCH PARTIAL not yet supported");
return PointerGetDatum(NULL);
}
- /* ----------
+ /*
* Never reached
- * ----------
*/
elog(ERROR, "internal error #7 in ri_triggers.c");
return PointerGetDatum(NULL);
@@ -1835,9 +1767,9 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
ReferentialIntegritySnapshotOverride = true;
- /* ----------
- * Check that this is a valid trigger call on the right time and event.
- * ----------
+ /*
+ * Check that this is a valid trigger call on the right time and
+ * event.
*/
if (!CALLED_AS_TRIGGER(fcinfo))
elog(ERROR, "RI_FKey_setnull_del() not fired by trigger manager");
@@ -1847,9 +1779,8 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
if (!TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
elog(ERROR, "RI_FKey_setnull_del() must be fired for DELETE");
- /* ----------
+ /*
* Check for the correct # of call arguments
- * ----------
*/
tgnargs = trigdata->tg_trigger->tgnargs;
tgargs = trigdata->tg_trigger->tgargs;
@@ -1859,17 +1790,15 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
elog(ERROR, "too many keys (%d max) in call to RI_FKey_setnull_del()",
RI_MAX_NUMKEYS);
- /* ----------
+ /*
* Nothing to do if no column names to compare given
- * ----------
*/
if (tgnargs == 4)
return PointerGetDatum(NULL);
- /* ----------
- * Get the relation descriptors of the FK and PK tables and
- * the old tuple.
- * ----------
+ /*
+ * Get the relation descriptors of the FK and PK tables and the old
+ * tuple.
*/
fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
pk_rel = trigdata->tg_relation;
@@ -1895,18 +1824,18 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
{
case RI_KEYS_ALL_NULL:
case RI_KEYS_SOME_NULL:
- /* ----------
+
+ /*
* No update - MATCH FULL means there cannot be any
* reference to old key if it contains NULL
- * ----------
*/
heap_close(fk_rel, NoLock);
return PointerGetDatum(NULL);
case RI_KEYS_NONE_NULL:
- /* ----------
+
+ /*
* Have a full qualified key - continue below
- * ----------
*/
break;
}
@@ -1915,10 +1844,9 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
if (SPI_connect() != SPI_OK_CONNECT)
elog(NOTICE, "SPI_connect() failed in RI_FKey_setnull_del()");
- /* ----------
+ /*
* Fetch or prepare a saved plan for the set null delete
* operation
- * ----------
*/
if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
{
@@ -1959,19 +1887,17 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
}
strcat(querystr, qualstr);
- /* ----------
+ /*
* Prepare, save and remember the new plan.
- * ----------
*/
qplan = SPI_prepare(querystr, qkey.nkeypairs, queryoids);
qplan = SPI_saveplan(qplan);
ri_HashPreparedPlan(&qkey, qplan);
}
- /* ----------
+ /*
* We have a plan now. Build up the arguments for SPI_execp()
* from the key values in the updated PK tuple.
- * ----------
*/
for (i = 0; i < qkey.nkeypairs; i++)
{
@@ -1986,9 +1912,8 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
}
upd_nulls[i] = '\0';
- /* ----------
+ /*
* Now update the existing references
- * ----------
*/
if (SPI_execp(qplan, upd_values, upd_nulls, 0) != SPI_OK_UPDATE)
elog(ERROR, "SPI_execp() failed in RI_FKey_setnull_del()");
@@ -1998,18 +1923,16 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS)
return PointerGetDatum(NULL);
- /* ----------
+ /*
* Handle MATCH PARTIAL set null delete.
- * ----------
*/
case RI_MATCH_TYPE_PARTIAL:
elog(ERROR, "MATCH PARTIAL not yet supported");
return PointerGetDatum(NULL);
}
- /* ----------
+ /*
* Never reached
- * ----------
*/
elog(ERROR, "internal error #8 in ri_triggers.c");
return PointerGetDatum(NULL);
@@ -2043,9 +1966,9 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
ReferentialIntegritySnapshotOverride = true;
- /* ----------
- * Check that this is a valid trigger call on the right time and event.
- * ----------
+ /*
+ * Check that this is a valid trigger call on the right time and
+ * event.
*/
if (!CALLED_AS_TRIGGER(fcinfo))
elog(ERROR, "RI_FKey_setnull_upd() not fired by trigger manager");
@@ -2055,9 +1978,8 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
elog(ERROR, "RI_FKey_setnull_upd() must be fired for UPDATE");
- /* ----------
+ /*
* Check for the correct # of call arguments
- * ----------
*/
tgnargs = trigdata->tg_trigger->tgnargs;
tgargs = trigdata->tg_trigger->tgargs;
@@ -2067,17 +1989,15 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
elog(ERROR, "too many keys (%d max) in call to RI_FKey_setnull_upd()",
RI_MAX_NUMKEYS);
- /* ----------
+ /*
* Nothing to do if no column names to compare given
- * ----------
*/
if (tgnargs == 4)
return PointerGetDatum(NULL);
- /* ----------
- * Get the relation descriptors of the FK and PK tables and
- * the old tuple.
- * ----------
+ /*
+ * Get the relation descriptors of the FK and PK tables and the old
+ * tuple.
*/
fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
pk_rel = trigdata->tg_relation;
@@ -2105,27 +2025,26 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
{
case RI_KEYS_ALL_NULL:
case RI_KEYS_SOME_NULL:
- /* ----------
+
+ /*
* No update - MATCH FULL means there cannot be any
* reference to old key if it contains NULL
- * ----------
*/
heap_close(fk_rel, NoLock);
return PointerGetDatum(NULL);
case RI_KEYS_NONE_NULL:
- /* ----------
+
+ /*
* Have a full qualified key - continue below
- * ----------
*/
break;
}
heap_close(fk_rel, NoLock);
- /* ----------
+ /*
* No need to do anything if old and new keys are equal
- * ----------
*/
if (ri_KeysEqual(pk_rel, old_row, new_row, &qkey,
RI_KEYPAIR_PK_IDX))
@@ -2152,10 +2071,9 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
ri_AllKeysUnequal(pk_rel, old_row, new_row,
&qkey, RI_KEYPAIR_PK_IDX);
- /* ----------
+ /*
* Fetch or prepare a saved plan for the set null update
* operation if possible, or build a temporary plan if not.
- * ----------
*/
if (!use_cached_query ||
(qplan = ri_FetchPreparedPlan(&qkey)) == NULL)
@@ -2207,9 +2125,8 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
}
strcat(querystr, qualstr);
- /* ----------
+ /*
* Prepare the new plan.
- * ----------
*/
qplan = SPI_prepare(querystr, qkey.nkeypairs, queryoids);
@@ -2224,10 +2141,9 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
}
}
- /* ----------
+ /*
* We have a plan now. Build up the arguments for SPI_execp()
* from the key values in the updated PK tuple.
- * ----------
*/
for (i = 0; i < qkey.nkeypairs; i++)
{
@@ -2242,9 +2158,8 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
}
upd_nulls[i] = '\0';
- /* ----------
+ /*
* Now update the existing references
- * ----------
*/
if (SPI_execp(qplan, upd_values, upd_nulls, 0) != SPI_OK_UPDATE)
elog(ERROR, "SPI_execp() failed in RI_FKey_setnull_upd()");
@@ -2254,18 +2169,16 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS)
return PointerGetDatum(NULL);
- /* ----------
+ /*
* Handle MATCH PARTIAL set null update.
- * ----------
*/
case RI_MATCH_TYPE_PARTIAL:
elog(ERROR, "MATCH PARTIAL not yet supported");
return PointerGetDatum(NULL);
}
- /* ----------
+ /*
* Never reached
- * ----------
*/
elog(ERROR, "internal error #9 in ri_triggers.c");
return PointerGetDatum(NULL);
@@ -2296,9 +2209,9 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
ReferentialIntegritySnapshotOverride = true;
- /* ----------
- * Check that this is a valid trigger call on the right time and event.
- * ----------
+ /*
+ * Check that this is a valid trigger call on the right time and
+ * event.
*/
if (!CALLED_AS_TRIGGER(fcinfo))
elog(ERROR, "RI_FKey_setdefault_del() not fired by trigger manager");
@@ -2308,9 +2221,8 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
if (!TRIGGER_FIRED_BY_DELETE(trigdata->tg_event))
elog(ERROR, "RI_FKey_setdefault_del() must be fired for DELETE");
- /* ----------
+ /*
* Check for the correct # of call arguments
- * ----------
*/
tgnargs = trigdata->tg_trigger->tgnargs;
tgargs = trigdata->tg_trigger->tgargs;
@@ -2320,17 +2232,15 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
elog(ERROR, "too many keys (%d max) in call to RI_FKey_setdefault_del()",
RI_MAX_NUMKEYS);
- /* ----------
+ /*
* Nothing to do if no column names to compare given
- * ----------
*/
if (tgnargs == 4)
return PointerGetDatum(NULL);
- /* ----------
- * Get the relation descriptors of the FK and PK tables and
- * the old tuple.
- * ----------
+ /*
+ * Get the relation descriptors of the FK and PK tables and the old
+ * tuple.
*/
fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
pk_rel = trigdata->tg_relation;
@@ -2356,18 +2266,18 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
{
case RI_KEYS_ALL_NULL:
case RI_KEYS_SOME_NULL:
- /* ----------
+
+ /*
* No update - MATCH FULL means there cannot be any
* reference to old key if it contains NULL
- * ----------
*/
heap_close(fk_rel, NoLock);
return PointerGetDatum(NULL);
case RI_KEYS_NONE_NULL:
- /* ----------
+
+ /*
* Have a full qualified key - continue below
- * ----------
*/
break;
}
@@ -2375,12 +2285,10 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
if (SPI_connect() != SPI_OK_CONNECT)
elog(NOTICE, "SPI_connect() failed in RI_FKey_setdefault_del()");
- /* ----------
+ /*
* Prepare a plan for the set defalt delete operation.
- * Unfortunately we need to do it on every invocation
- * because the default value could potentially change
- * between calls.
- * ----------
+ * Unfortunately we need to do it on every invocation because
+ * the default value could potentially change between calls.
*/
{
char buf[256];
@@ -2425,9 +2333,8 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
}
strcat(querystr, qualstr);
- /* ----------
+ /*
* Prepare the plan
- * ----------
*/
qplan = SPI_prepare(querystr, qkey.nkeypairs, queryoids);
@@ -2449,20 +2356,20 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
defval = NULL;
for (i = 0; i < qkey.nkeypairs && defval != NULL; i++)
{
- /* ----------
+
+ /*
* For each key attribute lookup the tuple constructor
* for a corresponding default value
- * ----------
*/
for (j = 0; j < fk_rel->rd_att->constr->num_defval; j++)
{
if (defval[j].adnum ==
qkey.keypair[i][RI_KEYPAIR_FK_IDX])
{
- /* ----------
- * That's the one - push the expression
- * from defval.adbin into the plan's targetlist
- * ----------
+
+ /*
+ * That's the one - push the expression from
+ * defval.adbin into the plan's targetlist
*/
spi_qptle = (TargetEntry *)
nth(defval[j].adnum - 1,
@@ -2477,10 +2384,9 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
/* fk_rel is no longer needed OK ? */
heap_close(fk_rel, NoLock);
- /* ----------
+ /*
* We have a plan now. Build up the arguments for SPI_execp()
* from the key values in the deleted PK tuple.
- * ----------
*/
for (i = 0; i < qkey.nkeypairs; i++)
{
@@ -2495,9 +2401,8 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
}
upd_nulls[i] = '\0';
- /* ----------
+ /*
* Now update the existing references
- * ----------
*/
if (SPI_execp(qplan, upd_values, upd_nulls, 0) != SPI_OK_UPDATE)
elog(ERROR, "SPI_execp() failed in RI_FKey_setdefault_del()");
@@ -2507,18 +2412,16 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS)
return PointerGetDatum(NULL);
- /* ----------
+ /*
* Handle MATCH PARTIAL set null delete.
- * ----------
*/
case RI_MATCH_TYPE_PARTIAL:
elog(ERROR, "MATCH PARTIAL not yet supported");
return PointerGetDatum(NULL);
}
- /* ----------
+ /*
* Never reached
- * ----------
*/
elog(ERROR, "internal error #10 in ri_triggers.c");
return PointerGetDatum(NULL);
@@ -2551,9 +2454,9 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
ReferentialIntegritySnapshotOverride = true;
- /* ----------
- * Check that this is a valid trigger call on the right time and event.
- * ----------
+ /*
+ * Check that this is a valid trigger call on the right time and
+ * event.
*/
if (!CALLED_AS_TRIGGER(fcinfo))
elog(ERROR, "RI_FKey_setdefault_upd() not fired by trigger manager");
@@ -2563,9 +2466,8 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
if (!TRIGGER_FIRED_BY_UPDATE(trigdata->tg_event))
elog(ERROR, "RI_FKey_setdefault_upd() must be fired for UPDATE");
- /* ----------
+ /*
* Check for the correct # of call arguments
- * ----------
*/
tgnargs = trigdata->tg_trigger->tgnargs;
tgargs = trigdata->tg_trigger->tgargs;
@@ -2575,17 +2477,15 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
elog(ERROR, "too many keys (%d max) in call to RI_FKey_setdefault_upd()",
RI_MAX_NUMKEYS);
- /* ----------
+ /*
* Nothing to do if no column names to compare given
- * ----------
*/
if (tgnargs == 4)
return PointerGetDatum(NULL);
- /* ----------
- * Get the relation descriptors of the FK and PK tables and
- * the old tuple.
- * ----------
+ /*
+ * Get the relation descriptors of the FK and PK tables and the old
+ * tuple.
*/
fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
pk_rel = trigdata->tg_relation;
@@ -2614,25 +2514,24 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
{
case RI_KEYS_ALL_NULL:
case RI_KEYS_SOME_NULL:
- /* ----------
+
+ /*
* No update - MATCH FULL means there cannot be any
* reference to old key if it contains NULL
- * ----------
*/
heap_close(fk_rel, NoLock);
return PointerGetDatum(NULL);
case RI_KEYS_NONE_NULL:
- /* ----------
+
+ /*
* Have a full qualified key - continue below
- * ----------
*/
break;
}
- /* ----------
+ /*
* No need to do anything if old and new keys are equal
- * ----------
*/
if (ri_KeysEqual(pk_rel, old_row, new_row, &qkey,
RI_KEYPAIR_PK_IDX))
@@ -2641,12 +2540,10 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
if (SPI_connect() != SPI_OK_CONNECT)
elog(NOTICE, "SPI_connect() failed in RI_FKey_setdefault_upd()");
- /* ----------
+ /*
* Prepare a plan for the set defalt delete operation.
- * Unfortunately we need to do it on every invocation
- * because the default value could potentially change
- * between calls.
- * ----------
+ * Unfortunately we need to do it on every invocation because
+ * the default value could potentially change between calls.
*/
{
char buf[256];
@@ -2701,17 +2598,15 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
}
strcat(querystr, qualstr);
- /* ----------
+ /*
* Prepare the plan
- * ----------
*/
qplan = SPI_prepare(querystr, qkey.nkeypairs, queryoids);
- /* ----------
- * Now replace the CONST NULL targetlist expressions
- * in the generated plan by (any) default values found
- * in the tuple constructor.
- * ----------
+ /*
+ * Now replace the CONST NULL targetlist expressions in
+ * the generated plan by (any) default values found in the
+ * tuple constructor.
*/
spi_plan = (Plan *) lfirst(((_SPI_plan *) qplan)->ptlist);
if (fk_rel->rd_att->constr != NULL)
@@ -2731,20 +2626,21 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
!ri_OneKeyEqual(pk_rel, i, old_row,
new_row, &qkey, RI_KEYPAIR_PK_IDX))
{
- /* ----------
- * For each key attribute lookup the tuple constructor
- * for a corresponding default value
- * ----------
+
+ /*
+ * For each key attribute lookup the tuple
+ * constructor for a corresponding default value
*/
for (j = 0; j < fk_rel->rd_att->constr->num_defval; j++)
{
if (defval[j].adnum ==
qkey.keypair[i][RI_KEYPAIR_FK_IDX])
{
- /* ----------
+
+ /*
* That's the one - push the expression
- * from defval.adbin into the plan's targetlist
- * ----------
+ * from defval.adbin into the plan's
+ * targetlist
*/
spi_qptle = (TargetEntry *)
nth(defval[j].adnum - 1,
@@ -2760,10 +2656,9 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
/* fk_rel is no longer needed OK ? */
heap_close(fk_rel, NoLock);
- /* ----------
+ /*
* We have a plan now. Build up the arguments for SPI_execp()
* from the key values in the deleted PK tuple.
- * ----------
*/
for (i = 0; i < qkey.nkeypairs; i++)
{
@@ -2778,9 +2673,8 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
}
upd_nulls[i] = '\0';
- /* ----------
+ /*
* Now update the existing references
- * ----------
*/
if (SPI_execp(qplan, upd_values, upd_nulls, 0) != SPI_OK_UPDATE)
elog(ERROR, "SPI_execp() failed in RI_FKey_setdefault_upd()");
@@ -2790,18 +2684,16 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS)
return PointerGetDatum(NULL);
- /* ----------
+ /*
* Handle MATCH PARTIAL set null delete.
- * ----------
*/
case RI_MATCH_TYPE_PARTIAL:
elog(ERROR, "MATCH PARTIAL not yet supported");
return PointerGetDatum(NULL);
}
- /* ----------
+ /*
* Never reached
- * ----------
*/
elog(ERROR, "internal error #11 in ri_triggers.c");
return PointerGetDatum(NULL);
@@ -2828,9 +2720,8 @@ RI_FKey_keyequal_upd(TriggerData *trigdata)
HeapTuple old_row;
RI_QueryKey qkey;
- /* ----------
+ /*
* Check for the correct # of call arguments
- * ----------
*/
tgnargs = trigdata->tg_trigger->tgnargs;
tgargs = trigdata->tg_trigger->tgargs;
@@ -2840,17 +2731,15 @@ RI_FKey_keyequal_upd(TriggerData *trigdata)
elog(ERROR, "too many keys (%d max) in call to RI_FKey_keyequal_upd()",
RI_MAX_NUMKEYS);
- /* ----------
+ /*
* Nothing to do if no column names to compare given
- * ----------
*/
if (tgnargs == 4)
return true;
- /* ----------
- * Get the relation descriptors of the FK and PK tables and
- * the new and old tuple.
- * ----------
+ /*
+ * Get the relation descriptors of the FK and PK tables and the new
+ * and old tuple.
*/
fk_rel = heap_openr(tgargs[RI_FK_RELNAME_ARGNO], NoLock);
pk_rel = trigdata->tg_relation;
@@ -2859,9 +2748,9 @@ RI_FKey_keyequal_upd(TriggerData *trigdata)
switch (ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]))
{
- /* ----------
+
+ /*
* MATCH <UNSPECIFIED>
- * ----------
*/
case RI_MATCH_TYPE_UNSPECIFIED:
case RI_MATCH_TYPE_FULL:
@@ -2871,25 +2760,22 @@ RI_FKey_keyequal_upd(TriggerData *trigdata)
tgnargs, tgargs);
heap_close(fk_rel, NoLock);
- /* ----------
+ /*
* Return if key's are equal
- * ----------
*/
return ri_KeysEqual(pk_rel, old_row, new_row, &qkey,
RI_KEYPAIR_PK_IDX);
- /* ----------
+ /*
* Handle MATCH PARTIAL set null delete.
- * ----------
*/
case RI_MATCH_TYPE_PARTIAL:
elog(ERROR, "MATCH PARTIAL not yet supported");
break;
}
- /* ----------
+ /*
* Never reached
- * ----------
*/
elog(ERROR, "internal error #12 in ri_triggers.c");
return false;
@@ -2955,9 +2841,8 @@ ri_BuildQueryKeyFull(RI_QueryKey *key, Oid constr_id, int32 constr_queryno,
int j;
int fno;
- /* ----------
+ /*
* Initialize the key and fill in type, oid's and number of keypairs
- * ----------
*/
memset((void *) key, 0, sizeof(RI_QueryKey));
key->constr_type = RI_MATCH_TYPE_FULL;
@@ -2967,10 +2852,9 @@ ri_BuildQueryKeyFull(RI_QueryKey *key, Oid constr_id, int32 constr_queryno,
key->pk_relid = pk_rel->rd_id;
key->nkeypairs = (argc - RI_FIRST_ATTNAME_ARGNO) / 2;
- /* ----------
+ /*
* Lookup the attribute numbers of the arguments to the trigger call
* and fill in the keypairs.
- * ----------
*/
for (i = 0, j = RI_FIRST_ATTNAME_ARGNO; j < argc; i++, j += 2)
{
@@ -3070,16 +2954,14 @@ ri_FetchPreparedPlan(RI_QueryKey *key)
RI_QueryHashEntry *entry;
bool found;
- /* ----------
+ /*
* On the first call initialize the hashtable
- * ----------
*/
if (!ri_query_cache)
ri_InitHashTables();
- /* ----------
+ /*
* Lookup for the key
- * ----------
*/
entry = (RI_QueryHashEntry *) hash_search(ri_query_cache,
(char *) key, HASH_FIND, &found);
@@ -3103,16 +2985,14 @@ ri_HashPreparedPlan(RI_QueryKey *key, void *plan)
RI_QueryHashEntry *entry;
bool found;
- /* ----------
+ /*
* On the first call initialize the hashtable
- * ----------
*/
if (!ri_query_cache)
ri_InitHashTables();
- /* ----------
+ /*
* Add the new plan.
- * ----------
*/
entry = (RI_QueryHashEntry *) hash_search(ri_query_cache,
(char *) key, HASH_ENTER, &found);
@@ -3140,28 +3020,26 @@ ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup,
for (i = 0; i < key->nkeypairs; i++)
{
- /* ----------
+
+ /*
* Get one attributes oldvalue. If it is NULL - they're not equal.
- * ----------
*/
oldvalue = SPI_getbinval(oldtup, rel->rd_att,
key->keypair[i][pairidx], &isnull);
if (isnull)
return false;
- /* ----------
+ /*
* Get one attributes oldvalue. If it is NULL - they're not equal.
- * ----------
*/
newvalue = SPI_getbinval(newtup, rel->rd_att,
key->keypair[i][pairidx], &isnull);
if (isnull)
return false;
- /* ----------
- * Get the attributes type OID and call the '=' operator
- * to compare the values.
- * ----------
+ /*
+ * Get the attributes type OID and call the '=' operator to
+ * compare the values.
*/
typeid = SPI_gettypeid(rel->rd_att, key->keypair[i][pairidx]);
if (!ri_AttributesEqual(typeid, oldvalue, newvalue))
@@ -3192,28 +3070,26 @@ ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup,
keys_unequal = true;
for (i = 0; keys_unequal && i < key->nkeypairs; i++)
{
- /* ----------
+
+ /*
* Get one attributes oldvalue. If it is NULL - they're not equal.
- * ----------
*/
oldvalue = SPI_getbinval(oldtup, rel->rd_att,
key->keypair[i][pairidx], &isnull);
if (isnull)
continue;
- /* ----------
+ /*
* Get one attributes oldvalue. If it is NULL - they're not equal.
- * ----------
*/
newvalue = SPI_getbinval(newtup, rel->rd_att,
key->keypair[i][pairidx], &isnull);
if (isnull)
continue;
- /* ----------
- * Get the attributes type OID and call the '=' operator
- * to compare the values.
- * ----------
+ /*
+ * Get the attributes type OID and call the '=' operator to
+ * compare the values.
*/
typeid = SPI_gettypeid(rel->rd_att, key->keypair[i][pairidx]);
if (!ri_AttributesEqual(typeid, oldvalue, newvalue))
@@ -3243,28 +3119,25 @@ ri_OneKeyEqual(Relation rel, int column, HeapTuple oldtup, HeapTuple newtup,
Datum newvalue;
bool isnull;
- /* ----------
+ /*
* Get one attributes oldvalue. If it is NULL - they're not equal.
- * ----------
*/
oldvalue = SPI_getbinval(oldtup, rel->rd_att,
key->keypair[column][pairidx], &isnull);
if (isnull)
return false;
- /* ----------
+ /*
* Get one attributes oldvalue. If it is NULL - they're not equal.
- * ----------
*/
newvalue = SPI_getbinval(newtup, rel->rd_att,
key->keypair[column][pairidx], &isnull);
if (isnull)
return false;
- /* ----------
- * Get the attributes type OID and call the '=' operator
- * to compare the values.
- * ----------
+ /*
+ * Get the attributes type OID and call the '=' operator to compare
+ * the values.
*/
typeid = SPI_gettypeid(rel->rd_att, key->keypair[column][pairidx]);
if (!ri_AttributesEqual(typeid, oldvalue, newvalue))
@@ -3289,27 +3162,24 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue)
RI_OpreqHashEntry *entry;
bool found;
- /* ----------
+ /*
* On the first call initialize the hashtable
- * ----------
*/
if (!ri_query_cache)
ri_InitHashTables();
- /* ----------
+ /*
* Try to find the '=' operator for this type in our cache
- * ----------
*/
entry = (RI_OpreqHashEntry *) hash_search(ri_opreq_cache,
(char *) &typeid, HASH_FIND, &found);
if (entry == NULL)
elog(FATAL, "error in RI operator cache");
- /* ----------
- * If not found, lookup the OPERNAME system cache for it
- * to get the func OID, then do the function manager lookup,
- * and remember that info.
- * ----------
+ /*
+ * If not found, lookup the OPERNAME system cache for it to get the
+ * func OID, then do the function manager lookup, and remember that
+ * info.
*/
if (!found)
{
@@ -3338,9 +3208,8 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue)
ReleaseSysCache(opr_tup);
}
- /* ----------
+ /*
* Call the type specific '=' function
- * ----------
*/
return DatumGetBool(FunctionCall2(&(entry->oprfmgrinfo),
oldvalue, newvalue));
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index c6db1c5b30f..b9aab50f628 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -3,7 +3,7 @@
* back to source text
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.74 2001/03/22 03:59:53 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.75 2001/03/22 06:16:18 momjian Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
@@ -163,24 +163,21 @@ pg_get_ruledef(PG_FUNCTION_ARGS)
StringInfoData buf;
int len;
- /* ----------
+ /*
* We need the rules name somewhere deep down: rulename is global
- * ----------
*/
rulename = pstrdup(NameStr(*rname));
- /* ----------
+ /*
* Connect to SPI manager
- * ----------
*/
if (SPI_connect() != SPI_OK_CONNECT)
elog(ERROR, "get_ruledef: cannot connect to SPI manager");
- /* ----------
- * On the first call prepare the plan to lookup pg_proc.
- * We read pg_proc over the SPI manager instead of using
- * the syscache to be checked for read access on pg_proc.
- * ----------
+ /*
+ * On the first call prepare the plan to lookup pg_proc. We read
+ * pg_proc over the SPI manager instead of using the syscache to be
+ * checked for read access on pg_proc.
*/
if (plan_getrule == NULL)
{
@@ -194,9 +191,8 @@ pg_get_ruledef(PG_FUNCTION_ARGS)
plan_getrule = SPI_saveplan(plan);
}
- /* ----------
+ /*
* Get the pg_rewrite tuple for this rule
- * ----------
*/
args[0] = PointerGetDatum(rulename);
nulls[0] = (rulename == NULL) ? 'n' : ' ';
@@ -217,9 +213,8 @@ pg_get_ruledef(PG_FUNCTION_ARGS)
ruletup = SPI_tuptable->vals[0];
rulettc = SPI_tuptable->tupdesc;
- /* ----------
+ /*
* Get the rules definition and put it into executors memory
- * ----------
*/
initStringInfo(&buf);
make_ruledef(&buf, ruletup, rulettc);
@@ -229,16 +224,14 @@ pg_get_ruledef(PG_FUNCTION_ARGS)
memcpy(VARDATA(ruledef), buf.data, buf.len);
pfree(buf.data);
- /* ----------
+ /*
* Disconnect from SPI manager
- * ----------
*/
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "get_ruledef: SPI_finish() failed");
- /* ----------
+ /*
* Easy - isn't it?
- * ----------
*/
PG_RETURN_TEXT_P(ruledef);
}
@@ -263,24 +256,21 @@ pg_get_viewdef(PG_FUNCTION_ARGS)
int len;
char *name;
- /* ----------
+ /*
* We need the view name somewhere deep down
- * ----------
*/
rulename = pstrdup(NameStr(*vname));
- /* ----------
+ /*
* Connect to SPI manager
- * ----------
*/
if (SPI_connect() != SPI_OK_CONNECT)
elog(ERROR, "get_viewdef: cannot connect to SPI manager");
- /* ----------
- * On the first call prepare the plan to lookup pg_proc.
- * We read pg_proc over the SPI manager instead of using
- * the syscache to be checked for read access on pg_proc.
- * ----------
+ /*
+ * On the first call prepare the plan to lookup pg_proc. We read
+ * pg_proc over the SPI manager instead of using the syscache to be
+ * checked for read access on pg_proc.
*/
if (plan_getview == NULL)
{
@@ -294,9 +284,9 @@ pg_get_viewdef(PG_FUNCTION_ARGS)
plan_getview = SPI_saveplan(plan);
}
- /* ----------
- * Get the pg_rewrite tuple for this rule: rulename is actually viewname here
- * ----------
+ /*
+ * Get the pg_rewrite tuple for this rule: rulename is actually
+ * viewname here
*/
name = MakeRetrieveViewRuleName(rulename);
args[0] = PointerGetDatum(name);
@@ -309,9 +299,9 @@ pg_get_viewdef(PG_FUNCTION_ARGS)
appendStringInfo(&buf, "Not a view");
else
{
- /* ----------
+
+ /*
* Get the rules definition and put it into executors memory
- * ----------
*/
ruletup = SPI_tuptable->vals[0];
rulettc = SPI_tuptable->tupdesc;
@@ -324,16 +314,14 @@ pg_get_viewdef(PG_FUNCTION_ARGS)
pfree(buf.data);
pfree(name);
- /* ----------
+ /*
* Disconnect from SPI manager
- * ----------
*/
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "get_viewdef: SPI_finish() failed");
- /* ----------
+ /*
* Easy - isn't it?
- * ----------
*/
PG_RETURN_TEXT_P(ruledef);
}
@@ -366,17 +354,14 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
StringInfoData keybuf;
char *sep;
- /* ----------
+ /*
* Connect to SPI manager
- * ----------
*/
if (SPI_connect() != SPI_OK_CONNECT)
elog(ERROR, "get_indexdef: cannot connect to SPI manager");
- /* ----------
- * On the first call prepare the plans to lookup pg_am
- * and pg_opclass.
- * ----------
+ /*
+ * On the first call prepare the plans to lookup pg_am and pg_opclass.
*/
if (plan_getam == NULL)
{
@@ -396,9 +381,8 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
plan_getopclass = SPI_saveplan(plan);
}
- /* ----------
+ /*
* Fetch the pg_index tuple by the Oid of the index
- * ----------
*/
ht_idx = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(indexrelid),
@@ -407,9 +391,8 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
elog(ERROR, "syscache lookup for index %u failed", indexrelid);
idxrec = (Form_pg_index) GETSTRUCT(ht_idx);
- /* ----------
+ /*
* Fetch the pg_class tuple of the index relation
- * ----------
*/
ht_idxrel = SearchSysCache(RELOID,
ObjectIdGetDatum(idxrec->indexrelid),
@@ -418,9 +401,8 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
elog(ERROR, "syscache lookup for relid %u failed", idxrec->indexrelid);
idxrelrec = (Form_pg_class) GETSTRUCT(ht_idxrel);
- /* ----------
+ /*
* Fetch the pg_class tuple of the indexed relation
- * ----------
*/
ht_indrel = SearchSysCache(RELOID,
ObjectIdGetDatum(idxrec->indrelid),
@@ -429,9 +411,8 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
elog(ERROR, "syscache lookup for relid %u failed", idxrec->indrelid);
indrelrec = (Form_pg_class) GETSTRUCT(ht_indrel);
- /* ----------
+ /*
* Get the am name for the index relation
- * ----------
*/
spi_args[0] = ObjectIdGetDatum(idxrelrec->relam);
spi_nulls[0] = ' ';
@@ -447,9 +428,8 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
spi_ttc = SPI_tuptable->tupdesc;
spi_fno = SPI_fnumber(spi_ttc, "amname");
- /* ----------
+ /*
* Start the index definition
- * ----------
*/
initStringInfo(&buf);
appendStringInfo(&buf, "CREATE %sINDEX %s ON %s USING %s (",
@@ -459,9 +439,8 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
quote_identifier(SPI_getvalue(spi_tup, spi_ttc,
spi_fno)));
- /* ----------
+ /*
* Collect the indexed attributes
- * ----------
*/
initStringInfo(&keybuf);
sep = "";
@@ -473,17 +452,15 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
appendStringInfo(&keybuf, sep);
sep = ", ";
- /* ----------
+ /*
* Add the indexed field name
- * ----------
*/
appendStringInfo(&keybuf, "%s",
quote_identifier(get_relid_attribute_name(idxrec->indrelid,
idxrec->indkey[keyno])));
- /* ----------
+ /*
* If not a functional index, add the operator class name
- * ----------
*/
if (idxrec->indproc == InvalidOid)
{
@@ -504,9 +481,8 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
}
}
- /* ----------
+ /*
* For functional index say 'func (attrs) opclass'
- * ----------
*/
if (idxrec->indproc != InvalidOid)
{
@@ -541,21 +517,19 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
ReleaseSysCache(proctup);
}
else
- /* ----------
+
+ /*
* For the others say 'attr opclass [, ...]'
- * ----------
*/
appendStringInfo(&buf, "%s", keybuf.data);
- /* ----------
+ /*
* Finish
- * ----------
*/
appendStringInfo(&buf, ")");
- /* ----------
+ /*
* Create the result in upper executor memory, and free objects
- * ----------
*/
len = buf.len + VARHDRSZ;
indexdef = SPI_palloc(len);
@@ -568,9 +542,8 @@ pg_get_indexdef(PG_FUNCTION_ARGS)
ReleaseSysCache(ht_idxrel);
ReleaseSysCache(ht_indrel);
- /* ----------
+ /*
* Disconnect from SPI manager
- * ----------
*/
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "get_viewdef: SPI_finish() failed");
@@ -592,16 +565,14 @@ pg_get_userbyid(PG_FUNCTION_ARGS)
HeapTuple usertup;
Form_pg_shadow user_rec;
- /* ----------
+ /*
* Allocate space for the result
- * ----------
*/
result = (Name) palloc(NAMEDATALEN);
memset(NameStr(*result), 0, NAMEDATALEN);
- /* ----------
+ /*
* Get the pg_shadow entry and print the result
- * ----------
*/
usertup = SearchSysCache(SHADOWSYSID,
ObjectIdGetDatum(uid),
@@ -705,9 +676,8 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc)
int fno;
bool isnull;
- /* ----------
+ /*
* Get the attribute values from the rules tuple
- * ----------
*/
fno = SPI_fnumber(rulettc, "ev_type");
ev_type = (char) SPI_getbinval(ruletup, rulettc, fno, &isnull);
@@ -730,9 +700,8 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc)
actions = (List *) stringToNode(ev_action);
- /* ----------
+ /*
* Build the rules definition text
- * ----------
*/
appendStringInfo(buf, "CREATE RULE %s AS ON ",
quote_identifier(rulename));
@@ -852,9 +821,8 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc)
int fno;
bool isnull;
- /* ----------
+ /*
* Get the attribute values from the rules tuple
- * ----------
*/
fno = SPI_fnumber(rulettc, "ev_type");
ev_type = (char) SPI_getbinval(ruletup, rulettc, fno, &isnull);
@@ -961,11 +929,10 @@ get_select_query_def(Query *query, deparse_context *context)
char *sep;
List *l;
- /* ----------
- * If the Query node has a setOperations tree, then it's the top
- * level of a UNION/INTERSECT/EXCEPT query; only the ORDER BY and
- * LIMIT fields are interesting in the top query itself.
- * ----------
+ /*
+ * If the Query node has a setOperations tree, then it's the top level
+ * of a UNION/INTERSECT/EXCEPT query; only the ORDER BY and LIMIT
+ * fields are interesting in the top query itself.
*/
if (query->setOperations)
{
@@ -1033,9 +1000,8 @@ get_basic_select_query(Query *query, deparse_context *context)
char *sep;
List *l;
- /* ----------
+ /*
* Build up the query string - first we say SELECT
- * ----------
*/
appendStringInfo(buf, "SELECT");
@@ -1230,10 +1196,9 @@ get_insert_query_def(Query *query, deparse_context *context)
char *sep;
List *l;
- /* ----------
+ /*
* If it's an INSERT ... SELECT there will be a single subquery RTE
* for the SELECT.
- * ----------
*/
foreach(l, query->rtable)
{
@@ -1245,9 +1210,8 @@ get_insert_query_def(Query *query, deparse_context *context)
select_rte = rte;
}
- /* ----------
+ /*
* Start the query with INSERT INTO relname
- * ----------
*/
rte = rt_fetch(query->resultRelation, query->rtable);
appendStringInfo(buf, "INSERT INTO %s",
@@ -1303,9 +1267,8 @@ get_update_query_def(Query *query, deparse_context *context)
RangeTblEntry *rte;
List *l;
- /* ----------
+ /*
* Start the query with UPDATE relname SET
- * ----------
*/
rte = rt_fetch(query->resultRelation, query->rtable);
appendStringInfo(buf, "UPDATE %s%s SET ",
@@ -1357,9 +1320,8 @@ get_delete_query_def(Query *query, deparse_context *context)
StringInfo buf = context->buf;
RangeTblEntry *rte;
- /* ----------
+ /*
* Start the query with DELETE FROM relname
- * ----------
*/
rte = rt_fetch(query->resultRelation, query->rtable);
appendStringInfo(buf, "DELETE FROM %s%s",
@@ -1681,14 +1643,13 @@ get_rule_expr(Node *node, deparse_context *context)
if (node == NULL)
return;
- /* ----------
+ /*
* Each level of get_rule_expr must emit an indivisible term
- * (parenthesized if necessary) to ensure result is reparsed into
- * the same expression tree.
+ * (parenthesized if necessary) to ensure result is reparsed into the
+ * same expression tree.
*
* There might be some work left here to support additional node types.
* Can we ever see Param nodes here?
- * ----------
*/
switch (nodeTag(node))
{
@@ -1722,9 +1683,8 @@ get_rule_expr(Node *node, deparse_context *context)
Expr *expr = (Expr *) node;
List *args = expr->args;
- /* ----------
+ /*
* Expr nodes have to be handled a bit detailed
- * ----------
*/
switch (expr->opType)
{
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index ef5f09374af..57a5dbe7126 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.82 2001/03/22 04:00:00 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.83 2001/03/22 06:16:18 momjian Exp $
*
*
*-------------------------------------------------------------------------
@@ -151,17 +151,17 @@ ReverifyMyDatabase(const char *name)
static void
InitCommunication(void)
{
- /* ----------------
- * initialize shared memory and semaphores appropriately.
- * ----------------
+
+ /*
+ * initialize shared memory and semaphores appropriately.
*/
if (!IsUnderPostmaster) /* postmaster already did this */
{
- /* ----------------
- * we're running a postgres backend by itself with
- * no front end or postmaster. Create private "shmem"
- * and semaphores. Setting MaxBackends = 16 is arbitrary.
- * ----------------
+
+ /*
+ * we're running a postgres backend by itself with no front end or
+ * postmaster. Create private "shmem" and semaphores. Setting
+ * MaxBackends = 16 is arbitrary.
*/
CreateSharedMemoryAndSemaphores(true, 16);
}
@@ -207,9 +207,8 @@ InitPostgres(const char *dbname, const char *username)
SetDatabaseName(dbname);
- /* ----------------
- * initialize the database id used for system caches and lock tables
- * ----------------
+ /*
+ * initialize the database id used for system caches and lock tables
*/
if (bootstrap)
{
diff --git a/src/backend/utils/misc/database.c b/src/backend/utils/misc/database.c
index 5e14ef778bd..21afef019c9 100644
--- a/src/backend/utils/misc/database.c
+++ b/src/backend/utils/misc/database.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.44 2001/03/22 04:00:06 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.45 2001/03/22 06:16:19 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -162,22 +162,20 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path)
pfree(dbfname);
- /* ----------------
- * read and examine every page in pg_database
+ /*
+ * read and examine every page in pg_database
+ *
+ * Raw I/O! Read those tuples the hard way! Yow!
*
- * Raw I/O! Read those tuples the hard way! Yow!
+ * Why don't we use the access methods or move this code someplace else?
+ * This is really pg_database schema dependent code. Perhaps it
+ * should go in lib/catalog/pg_database? -cim 10/3/90
*
- * Why don't we use the access methods or move this code
- * someplace else? This is really pg_database schema dependent
- * code. Perhaps it should go in lib/catalog/pg_database?
- * -cim 10/3/90
+ * mao replies 4 apr 91: yeah, maybe this should be moved to
+ * lib/catalog. however, we CANNOT use the access methods since those
+ * use the buffer cache, which uses the relation cache, which requires
+ * that the dbid be set, which is what we're trying to do here.
*
- * mao replies 4 apr 91: yeah, maybe this should be moved to
- * lib/catalog. however, we CANNOT use the access methods since
- * those use the buffer cache, which uses the relation cache, which
- * requires that the dbid be set, which is what we're trying to do
- * here.
- * ----------------
*/
pg = (Page) palloc(BLCKSZ);
@@ -199,16 +197,17 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path)
tup.t_datamcxt = NULL;
tup.t_data = (HeapTupleHeader) PageGetItem(pg, lpp);
- /*--------------------
+ /*
* Check to see if tuple is valid (committed).
*
* XXX warning, will robinson: violation of transaction semantics
- * happens right here. We cannot really determine if the tuple
- * is valid without checking transaction commit status, and the
- * only way to do that at init time is to paw over pg_log by hand,
- * too. Instead of checking, we assume that the inserting
- * transaction committed, and that any deleting transaction did
- * also, unless shown otherwise by on-row commit status bits.
+ * happens right here. We cannot really determine if the
+ * tuple is valid without checking transaction commit status,
+ * and the only way to do that at init time is to paw over
+ * pg_log by hand, too. Instead of checking, we assume that
+ * the inserting transaction committed, and that any deleting
+ * transaction did also, unless shown otherwise by on-row
+ * commit status bits.
*
* All in all, this code is pretty shaky. We will cross-check
* our result in ReverifyMyDatabase() in postinit.c.
@@ -221,7 +220,6 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path)
* XXX wouldn't it be better to let new backends read the
* database OID from a flat file, handled the same way we
* handle the password relation?
- *--------------------
*/
if (!PhonyHeapTupleSatisfiesNow(tup.t_data))
continue;