diff options
| author | Bruce Momjian | 2001-03-22 06:16:21 +0000 |
|---|---|---|
| committer | Bruce Momjian | 2001-03-22 06:16:21 +0000 |
| commit | 0686d49da0a34ad92f61f791ea1039dec5d20f41 (patch) | |
| tree | 11c8f58fb4364f5904c3cbad5c7a28ccea5d4049 /src/pl | |
| parent | 9e1552607a9dc6bc23e43d46770a9063ade4f3f0 (diff) | |
Remove dashes in comments that don't need them, rewrap with pgindent.
Diffstat (limited to 'src/pl')
| -rw-r--r-- | src/pl/plpgsql/src/pl_comp.c | 265 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_exec.c | 439 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_funcs.c | 18 | ||||
| -rw-r--r-- | src/pl/plpgsql/src/pl_handler.c | 28 |
4 files changed, 296 insertions, 454 deletions
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c index 1ea7a58aac1..213bedb28d1 100644 --- a/src/pl/plpgsql/src/pl_comp.c +++ b/src/pl/plpgsql/src/pl_comp.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.27 2001/03/22 04:01:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.28 2001/03/22 06:16:21 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -106,9 +106,8 @@ plpgsql_compile(Oid fn_oid, int functype) int i; int arg_varnos[FUNC_MAX_ARGS]; - /* ---------- + /* * Initialize the compiler - * ---------- */ plpgsql_ns_init(); plpgsql_ns_push(NULL); @@ -119,9 +118,8 @@ plpgsql_compile(Oid fn_oid, int functype) plpgsql_Datums = palloc(sizeof(PLpgSQL_datum *) * datums_alloc); datums_last = 0; - /* ---------- + /* * Lookup the pg_proc tuple by Oid - * ---------- */ procTup = SearchSysCache(PROCOID, ObjectIdGetDatum(fn_oid), @@ -129,9 +127,8 @@ plpgsql_compile(Oid fn_oid, int functype) if (!HeapTupleIsValid(procTup)) elog(ERROR, "plpgsql: cache lookup for proc %u failed", fn_oid); - /* ---------- + /* * Setup the scanner input and error info - * ---------- */ procStruct = (Form_pg_proc) GETSTRUCT(procTup); proc_source = DatumGetCString(DirectFunctionCall1(textout, @@ -141,9 +138,8 @@ plpgsql_compile(Oid fn_oid, int functype) NameGetDatum(&(procStruct->proname)))); plpgsql_error_lineno = 0; - /* ---------- + /* * Create the new function node - * ---------- */ function = malloc(sizeof(PLpgSQL_function)); memset(function, 0, sizeof(PLpgSQL_function)); @@ -157,16 +153,15 @@ plpgsql_compile(Oid fn_oid, int functype) switch (functype) { case T_FUNCTION: - /* ---------- + + /* * Normal function has a defined returntype - * ---------- */ function->fn_rettype = procStruct->prorettype; function->fn_retset = procStruct->proretset; - /* ---------- + /* * Lookup the functions return type - * ---------- */ typeTup = SearchSysCache(TYPEOID, ObjectIdGetDatum(procStruct->prorettype), @@ -193,17 +188,15 @@ plpgsql_compile(Oid fn_oid, int functype) } ReleaseSysCache(typeTup); - /* ---------- + /* * Create the variables for the procedures parameters - * ---------- */ for (i = 0; i < procStruct->pronargs; i++) { char buf[256]; - /* ---------- + /* * Get the parameters type - * ---------- */ typeTup = SearchSysCache(TYPEOID, ObjectIdGetDatum(procStruct->proargtypes[i]), @@ -221,10 +214,10 @@ plpgsql_compile(Oid fn_oid, int functype) if (typeStruct->typrelid != InvalidOid) { - /* ---------- - * For tuple type parameters, we set up a record - * of that type - * ---------- + + /* + * For tuple type parameters, we set up a record of + * that type */ sprintf(buf, "%s%%rowtype", DatumGetCString(DirectFunctionCall1(nameout, @@ -248,9 +241,9 @@ plpgsql_compile(Oid fn_oid, int functype) } else { - /* ---------- + + /* * Normal parameters get a var node - * ---------- */ var = malloc(sizeof(PLpgSQL_var)); memset(var, 0, sizeof(PLpgSQL_var)); @@ -282,18 +275,17 @@ plpgsql_compile(Oid fn_oid, int functype) break; case T_TRIGGER: - /* ---------- + + /* * Trigger procedures return type is unknown yet - * ---------- */ function->fn_rettype = InvalidOid; function->fn_retbyval = false; function->fn_retistuple = true; function->fn_retset = false; - /* ---------- + /* * Add the record for referencing NEW - * ---------- */ rec = malloc(sizeof(PLpgSQL_rec)); memset(rec, 0, sizeof(PLpgSQL_rec)); @@ -303,9 +295,8 @@ plpgsql_compile(Oid fn_oid, int functype) plpgsql_ns_additem(PLPGSQL_NSTYPE_REC, rec->recno, rec->refname); function->new_varno = rec->recno; - /* ---------- + /* * Add the record for referencing OLD - * ---------- */ rec = malloc(sizeof(PLpgSQL_rec)); memset(rec, 0, sizeof(PLpgSQL_rec)); @@ -315,9 +306,8 @@ plpgsql_compile(Oid fn_oid, int functype) plpgsql_ns_additem(PLPGSQL_NSTYPE_REC, rec->recno, rec->refname); function->old_varno = rec->recno; - /* ---------- + /* * Add the variable tg_name - * ---------- */ var = malloc(sizeof(PLpgSQL_var)); memset(var, 0, sizeof(PLpgSQL_var)); @@ -335,9 +325,8 @@ plpgsql_compile(Oid fn_oid, int functype) plpgsql_ns_additem(PLPGSQL_NSTYPE_VAR, var->varno, var->refname); function->tg_name_varno = var->varno; - /* ---------- + /* * Add the variable tg_when - * ---------- */ var = malloc(sizeof(PLpgSQL_var)); memset(var, 0, sizeof(PLpgSQL_var)); @@ -355,9 +344,8 @@ plpgsql_compile(Oid fn_oid, int functype) plpgsql_ns_additem(PLPGSQL_NSTYPE_VAR, var->varno, var->refname); function->tg_when_varno = var->varno; - /* ---------- + /* * Add the variable tg_level - * ---------- */ var = malloc(sizeof(PLpgSQL_var)); memset(var, 0, sizeof(PLpgSQL_var)); @@ -375,9 +363,8 @@ plpgsql_compile(Oid fn_oid, int functype) plpgsql_ns_additem(PLPGSQL_NSTYPE_VAR, var->varno, var->refname); function->tg_level_varno = var->varno; - /* ---------- + /* * Add the variable tg_op - * ---------- */ var = malloc(sizeof(PLpgSQL_var)); memset(var, 0, sizeof(PLpgSQL_var)); @@ -395,9 +382,8 @@ plpgsql_compile(Oid fn_oid, int functype) plpgsql_ns_additem(PLPGSQL_NSTYPE_VAR, var->varno, var->refname); function->tg_op_varno = var->varno; - /* ---------- + /* * Add the variable tg_relid - * ---------- */ var = malloc(sizeof(PLpgSQL_var)); memset(var, 0, sizeof(PLpgSQL_var)); @@ -415,9 +401,8 @@ plpgsql_compile(Oid fn_oid, int functype) plpgsql_ns_additem(PLPGSQL_NSTYPE_VAR, var->varno, var->refname); function->tg_relid_varno = var->varno; - /* ---------- + /* * Add the variable tg_relname - * ---------- */ var = malloc(sizeof(PLpgSQL_var)); memset(var, 0, sizeof(PLpgSQL_var)); @@ -435,9 +420,8 @@ plpgsql_compile(Oid fn_oid, int functype) plpgsql_ns_additem(PLPGSQL_NSTYPE_VAR, var->varno, var->refname); function->tg_relname_varno = var->varno; - /* ---------- + /* * Add the variable tg_nargs - * ---------- */ var = malloc(sizeof(PLpgSQL_var)); memset(var, 0, sizeof(PLpgSQL_var)); @@ -463,10 +447,9 @@ plpgsql_compile(Oid fn_oid, int functype) break; } - /* ---------- - * Create the magic found variable indicating if the - * last FOR or SELECT statement returned data - * ---------- + /* + * Create the magic found variable indicating if the last FOR or + * SELECT statement returned data */ var = malloc(sizeof(PLpgSQL_var)); memset(var, 0, sizeof(PLpgSQL_var)); @@ -484,15 +467,13 @@ plpgsql_compile(Oid fn_oid, int functype) plpgsql_ns_additem(PLPGSQL_NSTYPE_VAR, var->varno, strdup("found")); function->found_varno = var->varno; - /* ---------- + /* * Forget about the above created variables - * ---------- */ plpgsql_add_initdatums(NULL); - /* ---------- + /* * Now parse the functions text - * ---------- */ parse_rc = plpgsql_yyparse(); if (parse_rc != 0) @@ -501,9 +482,8 @@ plpgsql_compile(Oid fn_oid, int functype) elog(ERROR, "plpgsql: parser returned %d ???", parse_rc); } - /* ---------- + /* * If that was successful, complete the functions info. - * ---------- */ function->fn_nargs = procStruct->pronargs; for (i = 0; i < function->fn_nargs; i++) @@ -516,9 +496,8 @@ plpgsql_compile(Oid fn_oid, int functype) ReleaseSysCache(procTup); - /* ---------- + /* * Finally return the compiled function - * ---------- */ if (plpgsql_DumpExecTree) plpgsql_dumptree(function); @@ -541,15 +520,13 @@ plpgsql_parse_word(char *word) Form_pg_type typeStruct; char *typeXlated; - /* ---------- + /* * We do our lookups case insensitive - * ---------- */ cp = plpgsql_tolower(word); - /* ---------- + /* * Special handling when compiling triggers - * ---------- */ if (plpgsql_curr_compile->fn_functype == T_TRIGGER) { @@ -575,9 +552,8 @@ plpgsql_parse_word(char *word) } } - /* ---------- + /* * Do a lookup on the compilers namestack - * ---------- */ nse = plpgsql_ns_lookup(cp, NULL); if (nse != NULL) @@ -605,10 +581,9 @@ plpgsql_parse_word(char *word) } } - /* ---------- - * Try to find a data type with that name, but ignore - * pg_type entries that are in fact class types. - * ---------- + /* + * Try to find a data type with that name, but ignore pg_type entries + * that are in fact class types. */ typeXlated = xlateSqlType(cp); typeTup = SearchSysCache(TYPENAME, @@ -644,10 +619,9 @@ plpgsql_parse_word(char *word) return T_DTYPE; } - /* ---------- - * Nothing found - up to now it's a word without any - * special meaning for us. - * ---------- + /* + * Nothing found - up to now it's a word without any special meaning + * for us. */ pfree(cp); return T_WORD; @@ -666,17 +640,15 @@ plpgsql_parse_dblword(char *string) char *word2; PLpgSQL_nsitem *ns; - /* ---------- + /* * Convert to lower case and separate the words - * ---------- */ word1 = plpgsql_tolower(string); word2 = strchr(word1, '.'); *word2++ = '\0'; - /* ---------- + /* * Lookup the first word - * ---------- */ ns = plpgsql_ns_lookup(word1, NULL); if (ns == NULL) @@ -688,13 +660,12 @@ plpgsql_parse_dblword(char *string) switch (ns->itemtype) { case PLPGSQL_NSTYPE_LABEL: - /* ---------- - * First word is a label, so second word could be - * a variable, record or row in that bodies namestack. - * Anything else could only be something in a query - * given to the SPI manager and T_ERROR will get eaten - * up by the collector routines. - * ---------- + + /* + * First word is a label, so second word could be a variable, + * record or row in that bodies namestack. Anything else could + * only be something in a query given to the SPI manager and + * T_ERROR will get eaten up by the collector routines. */ ns = plpgsql_ns_lookup(word2, word1); if (ns == NULL) @@ -726,10 +697,10 @@ plpgsql_parse_dblword(char *string) case PLPGSQL_NSTYPE_REC: { - /* ---------- - * First word is a record name, so second word - * must be a field in this record. - * ---------- + + /* + * First word is a record name, so second word must be a + * field in this record. */ PLpgSQL_recfield *new; @@ -747,10 +718,10 @@ plpgsql_parse_dblword(char *string) case PLPGSQL_NSTYPE_ROW: { - /* ---------- - * First word is a row name, so second word must - * be a field in this row. - * ---------- + + /* + * First word is a row name, so second word must be a + * field in this row. */ PLpgSQL_row *row; int i; @@ -792,9 +763,8 @@ plpgsql_parse_tripword(char *string) char *word3; PLpgSQL_nsitem *ns; - /* ---------- + /* * Convert to lower case and separate the words - * ---------- */ word1 = plpgsql_tolower(string); word2 = strchr(word1, '.'); @@ -802,9 +772,8 @@ plpgsql_parse_tripword(char *string) word3 = strchr(word2, '.'); *word3++ = '\0'; - /* ---------- + /* * Lookup the first word - it must be a label - * ---------- */ ns = plpgsql_ns_lookup(word1, NULL); if (ns == NULL) @@ -818,10 +787,8 @@ plpgsql_parse_tripword(char *string) return T_ERROR; } - /* ---------- - * First word is a label, so second word could be - * a record or row - * ---------- + /* + * First word is a label, so second word could be a record or row */ ns = plpgsql_ns_lookup(word2, word1); if (ns == NULL) @@ -834,10 +801,10 @@ plpgsql_parse_tripword(char *string) { case PLPGSQL_NSTYPE_REC: { - /* ---------- - * This word is a record name, so third word - * must be a field in this record. - * ---------- + + /* + * This word is a record name, so third word must be a + * field in this record. */ PLpgSQL_recfield *new; @@ -855,10 +822,10 @@ plpgsql_parse_tripword(char *string) case PLPGSQL_NSTYPE_ROW: { - /* ---------- - * This word is a row name, so third word must - * be a field in this row. - * ---------- + + /* + * This word is a row name, so third word must be a field + * in this row. */ PLpgSQL_row *row; int i; @@ -902,17 +869,15 @@ plpgsql_parse_wordtype(char *word) char *typeXlated; bool old_nsstate; - /* ---------- + /* * We do our lookups case insensitive - * ---------- */ cp = plpgsql_tolower(word); *(strchr(cp, '%')) = '\0'; - /* ---------- - * Do a lookup on the compilers namestack. - * But ensure it moves up to the toplevel. - * ---------- + /* + * Do a lookup on the compilers namestack. But ensure it moves up to + * the toplevel. */ old_nsstate = plpgsql_ns_setlocal(false); nse = plpgsql_ns_lookup(cp, NULL); @@ -932,11 +897,9 @@ plpgsql_parse_wordtype(char *word) } } - /* ---------- - * Word wasn't found on the namestack. - * Try to find a data type with that name, but ignore - * pg_type entries that are in fact class types. - * ---------- + /* + * Word wasn't found on the namestack. Try to find a data type with + * that name, but ignore pg_type entries that are in fact class types. */ typeXlated = xlateSqlType(cp); typeTup = SearchSysCache(TYPENAME, @@ -972,10 +935,9 @@ plpgsql_parse_wordtype(char *word) return T_DTYPE; } - /* ---------- - * Nothing found - up to now it's a word without any - * special meaning for us. - * ---------- + /* + * Nothing found - up to now it's a word without any special meaning + * for us. */ pfree(cp); return T_ERROR; @@ -1002,25 +964,22 @@ plpgsql_parse_dblwordtype(char *string) PLpgSQL_type *typ; - /* ---------- + /* * Convert to lower case and separate the words - * ---------- */ word1 = plpgsql_tolower(string); word2 = strchr(word1, '.'); *word2++ = '\0'; *(strchr(word2, '%')) = '\0'; - /* ---------- + /* * Lookup the first word - * ---------- */ nse = plpgsql_ns_lookup(word1, NULL); - /* ---------- - * If this is a label lookup the second word in that - * labels namestack level - * ---------- + /* + * If this is a label lookup the second word in that labels namestack + * level */ if (nse != NULL) { @@ -1050,9 +1009,8 @@ plpgsql_parse_dblwordtype(char *string) return T_ERROR; } - /* ---------- + /* * First word could also be a table name - * ---------- */ classtup = SearchSysCache(RELNAME, PointerGetDatum(word1), @@ -1063,9 +1021,8 @@ plpgsql_parse_dblwordtype(char *string) return T_ERROR; } - /* ---------- + /* * It must be a (shared) relation class - * ---------- */ classStruct = (Form_pg_class) GETSTRUCT(classtup); if (classStruct->relkind != 'r' && classStruct->relkind != 's') @@ -1075,9 +1032,8 @@ plpgsql_parse_dblwordtype(char *string) return T_ERROR; } - /* ---------- + /* * Fetch the named table field and it's type - * ---------- */ attrtup = SearchSysCache(ATTNAME, ObjectIdGetDatum(classtup->t_data->t_oid), @@ -1102,9 +1058,8 @@ plpgsql_parse_dblwordtype(char *string) } typeStruct = (Form_pg_type) GETSTRUCT(typetup); - /* ---------- + /* * Found that - build a compiler type struct and return it - * ---------- */ typ = (PLpgSQL_type *) malloc(sizeof(PLpgSQL_type)); @@ -1146,9 +1101,8 @@ plpgsql_parse_wordrowtype(char *string) PLpgSQL_row *row; PLpgSQL_var *var; - /* ---------- + /* * Get the word in lower case and fetch the pg_class tuple. - * ---------- */ word1 = plpgsql_tolower(string); cp = strchr(word1, '%'); @@ -1169,9 +1123,8 @@ plpgsql_parse_wordrowtype(char *string) elog(ERROR, "%s isn't a table", word1); } - /* ---------- + /* * Fetch the tables pg_type tuple too - * ---------- */ typetup = SearchSysCache(TYPENAME, PointerGetDatum(word1), @@ -1182,10 +1135,9 @@ plpgsql_parse_wordrowtype(char *string) elog(ERROR, "cache lookup for %s in pg_type failed", word1); } - /* ---------- - * Create a row datum entry and all the required variables - * that it will point to. - * ---------- + /* + * Create a row datum entry and all the required variables that it + * will point to. */ row = malloc(sizeof(PLpgSQL_row)); memset(row, 0, sizeof(PLpgSQL_row)); @@ -1200,9 +1152,9 @@ plpgsql_parse_wordrowtype(char *string) for (i = 0; i < row->nfields; i++) { - /* ---------- + + /* * Get the attribute and it's type - * ---------- */ attrtup = SearchSysCache(ATTNUM, ObjectIdGetDatum(classtup->t_data->t_oid), @@ -1230,15 +1182,14 @@ plpgsql_parse_wordrowtype(char *string) } typeStruct = (Form_pg_type) GETSTRUCT(typetup); - /* ---------- - * Create the internal variable - * We know if the table definitions contain a default value - * or if the field is declared in the table as NOT NULL. But - * it's possible to create a table field as NOT NULL without - * a default value and that would lead to problems later when - * initializing the variables due to entering a block at - * execution time. Thus we ignore this information for now. - * ---------- + /* + * Create the internal variable We know if the table definitions + * contain a default value or if the field is declared in the + * table as NOT NULL. But it's possible to create a table field as + * NOT NULL without a default value and that would lead to + * problems later when initializing the variables due to entering + * a block at execution time. Thus we ignore this information for + * now. */ var = malloc(sizeof(PLpgSQL_var)); var->dtype = PLPGSQL_DTYPE_VAR; @@ -1265,9 +1216,8 @@ plpgsql_parse_wordrowtype(char *string) plpgsql_adddatum((PLpgSQL_datum *) var); - /* ---------- + /* * Add the variable to the row. - * ---------- */ row->fieldnames[i] = cp; row->varnos[i] = var->varno; @@ -1275,9 +1225,8 @@ plpgsql_parse_wordrowtype(char *string) ReleaseSysCache(classtup); - /* ---------- + /* * Return the complete row definition - * ---------- */ plpgsql_yylval.row = row; diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index c51a633af85..7a65b6512d7 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.39 2001/03/22 04:01:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_exec.c,v 1.40 2001/03/22 06:16:21 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -157,9 +157,8 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) PLpgSQL_stmt *save_estmt; char *save_etext; - /* ---------- + /* * Setup debug error info and catch elog() - * ---------- */ save_efunc = error_info_func; save_estmt = error_info_stmt; @@ -174,10 +173,9 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) { memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart)); - /* ---------- - * If we are the first of cascaded error catchings, - * print where this happened - * ---------- + /* + * If we are the first of cascaded error catchings, print where + * this happened */ if (error_info_func != NULL) { @@ -258,9 +256,8 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) } - /* ---------- + /* * Setup the execution state - * ---------- */ estate.retval = 0; estate.retisnull = false; @@ -273,9 +270,8 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) estate.ndatums = func->ndatums; estate.datums = palloc(sizeof(PLpgSQL_datum *) * estate.ndatums); - /* ---------- + /* * Make local execution copies of all the datums - * ---------- */ for (i = 0; i < func->ndatums; i++) { @@ -302,9 +298,8 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) } } - /* ---------- + /* * Put the actual call argument values into the variables - * ---------- */ error_info_text = "while putting call arguments to local variables"; for (i = 0; i < func->fn_nargs; i++) @@ -343,10 +338,9 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) } } - /* ---------- - * Initialize the other variables to NULL values for now. - * The default values are set when the blocks are entered. - * ---------- + /* + * Initialize the other variables to NULL values for now. The default + * values are set when the blocks are entered. */ error_info_text = "while initializing local variables to NULL"; for (i = estate.found_varno; i < estate.ndatums; i++) @@ -374,15 +368,13 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) } } - /* ---------- + /* * Set the magic variable FOUND to false - * ---------- */ exec_set_found(&estate, false); - /* ---------- + /* * Now call the toplevel block of statements - * ---------- */ error_info_text = NULL; error_info_stmt = (PLpgSQL_stmt *) (func->action); @@ -393,9 +385,8 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) elog(ERROR, "control reaches end of function without RETURN"); } - /* ---------- + /* * We got a return value - process it - * ---------- */ error_info_stmt = NULL; error_info_text = "while casting return value to functions return type"; @@ -411,10 +402,9 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) -1, &fcinfo->isnull); - /* ---------- - * If the functions return type isn't by value, - * copy the value into upper executor memory context. - * ---------- + /* + * If the functions return type isn't by value, copy the value + * into upper executor memory context. */ if (!fcinfo->isnull && !func->fn_retbyval) { @@ -432,18 +422,16 @@ plpgsql_exec_function(PLpgSQL_function * func, FunctionCallInfo fcinfo) } } - /* ---------- + /* * Restore the previous error info and elog() jump target - * ---------- */ error_info_func = save_efunc; error_info_stmt = save_estmt; error_info_text = save_etext; memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart)); - /* ---------- + /* * Return the functions result - * ---------- */ return estate.retval; } @@ -469,9 +457,8 @@ plpgsql_exec_trigger(PLpgSQL_function * func, PLpgSQL_var *var; HeapTuple rettup; - /* ---------- + /* * Setup debug error info and catch elog() - * ---------- */ save_efunc = error_info_func; save_estmt = error_info_stmt; @@ -486,10 +473,9 @@ plpgsql_exec_trigger(PLpgSQL_function * func, { memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart)); - /* ---------- - * If we are the first of cascaded error catchings, - * print where this happened - * ---------- + /* + * If we are the first of cascaded error catchings, print where + * this happened */ if (error_info_func != NULL) { @@ -570,9 +556,8 @@ plpgsql_exec_trigger(PLpgSQL_function * func, } - /* ---------- + /* * Setup the execution state - * ---------- */ estate.retval = 0; estate.retisnull = false; @@ -585,9 +570,8 @@ plpgsql_exec_trigger(PLpgSQL_function * func, estate.ndatums = func->ndatums; estate.datums = palloc(sizeof(PLpgSQL_datum *) * estate.ndatums); - /* ---------- + /* * Make local execution copies of all the datums - * ---------- */ for (i = 0; i < func->ndatums; i++) { @@ -615,10 +599,9 @@ plpgsql_exec_trigger(PLpgSQL_function * func, } } - /* ---------- - * Put the trig and new tuples into the records - * and set the tg_op variable - * ---------- + /* + * Put the trig and new tuples into the records and set the tg_op + * variable */ rec_new = (PLpgSQL_rec *) (estate.datums[func->new_varno]); rec_old = (PLpgSQL_rec *) (estate.datums[func->old_varno]); @@ -656,9 +639,8 @@ plpgsql_exec_trigger(PLpgSQL_function * func, var->value = DirectFunctionCall1(textin, CStringGetDatum("UNKNOWN")); } - /* ---------- + /* * Fill all the other special tg_ variables - * ---------- */ var = (PLpgSQL_var *) (estate.datums[func->tg_name_varno]); var->isnull = false; @@ -696,10 +678,9 @@ plpgsql_exec_trigger(PLpgSQL_function * func, var->isnull = false; var->value = (Datum) (trigdata->tg_trigger->tgnargs); - /* ---------- - * Put the actual call argument values into the special - * execution state variables - * ---------- + /* + * Put the actual call argument values into the special execution + * state variables */ error_info_text = "while putting call arguments to local variables"; estate.trig_nargs = trigdata->tg_trigger->tgnargs; @@ -713,10 +694,9 @@ plpgsql_exec_trigger(PLpgSQL_function * func, CStringGetDatum(trigdata->tg_trigger->tgargs[i])); } - /* ---------- - * Initialize the other variables to NULL values for now. - * The default values are set when the blocks are entered. - * ---------- + /* + * Initialize the other variables to NULL values for now. The default + * values are set when the blocks are entered. */ error_info_text = "while initializing local variables to NULL"; for (i = estate.found_varno; i < estate.ndatums; i++) @@ -745,15 +725,13 @@ plpgsql_exec_trigger(PLpgSQL_function * func, } } - /* ---------- + /* * Set the magic variable FOUND to false - * ---------- */ exec_set_found(&estate, false); - /* ---------- + /* * Now call the toplevel block of statements - * ---------- */ error_info_text = NULL; error_info_stmt = (PLpgSQL_stmt *) (func->action); @@ -764,15 +742,13 @@ plpgsql_exec_trigger(PLpgSQL_function * func, elog(ERROR, "control reaches end of trigger procedure without RETURN"); } - /* ---------- + /* * Check that the returned tuple structure has the same attributes, * the relation that fired the trigger has. * - * XXX This way it is possible, that the trigger returns a tuple - * where attributes don't have the correct atttypmod's length. - * It's up to the trigger's programmer to ensure that this - * doesn't happen. Jan - * ---------- + * XXX This way it is possible, that the trigger returns a tuple where + * attributes don't have the correct atttypmod's length. It's up to + * the trigger's programmer to ensure that this doesn't happen. Jan */ if (estate.retisnull) rettup = NULL; @@ -793,18 +769,16 @@ plpgsql_exec_trigger(PLpgSQL_function * func, rettup = SPI_copytuple((HeapTuple) (estate.retval)); } - /* ---------- + /* * Restore the previous error info and elog() jump target - * ---------- */ error_info_func = save_efunc; error_info_stmt = save_estmt; error_info_text = save_etext; memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart)); - /* ---------- + /* * Return the triggers result - * ---------- */ return rettup; } @@ -847,9 +821,8 @@ exec_stmt_block(PLpgSQL_execstate * estate, PLpgSQL_stmt_block * block) int i; int n; - /* ---------- + /* * First initialize all variables declared in this block - * ---------- */ for (i = 0; i < block->n_initvars; i++) { @@ -897,15 +870,13 @@ exec_stmt_block(PLpgSQL_execstate * estate, PLpgSQL_stmt_block * block) } - /* ---------- + /* * Execute the statements in the block's body - * ---------- */ rc = exec_stmts(estate, block->body); - /* ---------- + /* * Handle the return code. - * ---------- */ switch (rc) { @@ -1242,9 +1213,8 @@ exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt) bool isnull = false; int rc; - /* ---------- + /* * Get the value of the lower bound into the loop var - * ---------- */ value = exec_eval_expr(estate, stmt->lower, &isnull, &valtype); var = (PLpgSQL_var *) (estate->datums[stmt->var->varno]); @@ -1258,9 +1228,8 @@ exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt) var->value = value; var->isnull = false; - /* ---------- + /* * Get the value of the upper bound - * ---------- */ value = exec_eval_expr(estate, stmt->upper, &isnull, &valtype); value = exec_cast_value(value, valtype, var->datatype->typoid, @@ -1270,16 +1239,15 @@ exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt) if (isnull) elog(ERROR, "upper bound of FOR loop cannot be NULL"); - /* ---------- + /* * Now do the loop - * ---------- */ exec_set_found(estate, false); for (;;) { - /* ---------- + + /* * Check bounds - * ---------- */ if (stmt->reverse) { @@ -1293,15 +1261,13 @@ exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt) } exec_set_found(estate, true); - /* ---------- + /* * Execute the statements - * ---------- */ rc = exec_stmts(estate, stmt->body); - /* ---------- + /* * Check returncode - * ---------- */ switch (rc) { @@ -1325,9 +1291,8 @@ exec_stmt_fori(PLpgSQL_execstate * estate, PLpgSQL_stmt_fori * stmt) elog(ERROR, "unknown rc %d from exec_stmts()", rc); } - /* ---------- + /* * Increase/decrease loop var - * ---------- */ if (stmt->reverse) var->value--; @@ -1356,15 +1321,13 @@ exec_stmt_fors(PLpgSQL_execstate * estate, PLpgSQL_stmt_fors * stmt) int i; int n; - /* ---------- + /* * Initialize the global found variable to false - * ---------- */ exec_set_found(estate, false); - /* ---------- + /* * Determine if we assign to a record or a row - * ---------- */ if (stmt->rec != NULL) rec = (PLpgSQL_rec *) (estate->datums[stmt->rec->recno]); @@ -1376,17 +1339,15 @@ exec_stmt_fors(PLpgSQL_execstate * estate, PLpgSQL_stmt_fors * stmt) elog(ERROR, "unsupported target in exec_stmt_fors()"); } - /* ---------- + /* * Run the query - * ---------- */ exec_run_select(estate, stmt->query, 0); n = SPI_processed; - /* ---------- - * If the query didn't return any row, set the target - * to NULL and return. - * ---------- + /* + * If the query didn't return any row, set the target to NULL and + * return. */ if (n == 0) { @@ -1394,36 +1355,32 @@ exec_stmt_fors(PLpgSQL_execstate * estate, PLpgSQL_stmt_fors * stmt) return PLPGSQL_RC_OK; } - /* ---------- + /* * There are tuples, so set found to true - * ---------- */ exec_set_found(estate, true); - /* ---------- + /* * Now do the loop - * ---------- */ tuptab = SPI_tuptable; SPI_tuptable = NULL; for (i = 0; i < n; i++) { - /* ---------- + + /* * Assign the tuple to the target - * ---------- */ exec_move_row(estate, rec, row, tuptab->vals[i], tuptab->tupdesc); - /* ---------- + /* * Execute the statements - * ---------- */ rc = exec_stmts(estate, stmt->body); - /* ---------- + /* * Check returncode - * ---------- */ switch (rc) { @@ -1465,15 +1422,13 @@ exec_stmt_select(PLpgSQL_execstate * estate, PLpgSQL_stmt_select * stmt) SPITupleTable *tuptab; int n; - /* ---------- + /* * Initialize the global found variable to false - * ---------- */ exec_set_found(estate, false); - /* ---------- + /* * Determine if we assign to a record or a row - * ---------- */ if (stmt->rec != NULL) rec = (PLpgSQL_rec *) (estate->datums[stmt->rec->recno]); @@ -1485,17 +1440,15 @@ exec_stmt_select(PLpgSQL_execstate * estate, PLpgSQL_stmt_select * stmt) elog(ERROR, "unsupported target in exec_stmt_select()"); } - /* ---------- + /* * Run the query - * ---------- */ exec_run_select(estate, stmt->query, 1); n = SPI_processed; - /* ---------- - * If the query didn't return any row, set the target - * to NULL and return. - * ---------- + /* + * If the query didn't return any row, set the target to NULL and + * return. */ if (n == 0) { @@ -1503,9 +1456,8 @@ exec_stmt_select(PLpgSQL_execstate * estate, PLpgSQL_stmt_select * stmt) return PLPGSQL_RC_OK; } - /* ---------- + /* * Put the result into the target and set found to true - * ---------- */ tuptab = SPI_tuptable; SPI_tuptable = NULL; @@ -1529,9 +1481,8 @@ exec_stmt_exit(PLpgSQL_execstate * estate, PLpgSQL_stmt_exit * stmt) Oid valtype; bool isnull = false; - /* ---------- + /* * If the exit has a condition, check that it's true - * ---------- */ if (stmt->cond != NULL) { @@ -1615,11 +1566,11 @@ exec_stmt_raise(PLpgSQL_execstate * estate, PLpgSQL_stmt_raise * stmt) for (cp = stmt->message; *cp; cp++) { - /* ---------- - * Occurences of a single % are replaced by the next - * arguments external representation. Double %'s are - * left as is so elog() will also don't touch them. - * ---------- + + /* + * Occurences of a single % are replaced by the next arguments + * external representation. Double %'s are left as is so elog() + * will also don't touch them. */ if ((c[0] = *cp) == '%') { @@ -1717,10 +1668,9 @@ exec_stmt_raise(PLpgSQL_execstate * estate, PLpgSQL_stmt_raise * stmt) continue; } - /* ---------- - * Occurences of single ' are removed. double ' are reduced - * to single ones. - * ---------- + /* + * Occurences of single ' are removed. double ' are reduced to + * single ones. */ if (*cp == '\'') { @@ -1734,9 +1684,8 @@ exec_stmt_raise(PLpgSQL_execstate * estate, PLpgSQL_stmt_raise * stmt) plpgsql_dstring_append(&ds, c); } - /* ---------- + /* * Now suppress debug info and throw the elog() - * ---------- */ if (stmt->elog_level == ERROR) { @@ -1767,9 +1716,8 @@ exec_prepare_plan(PLpgSQL_execstate * estate, void *plan; Oid *argtypes; - /* ---------- + /* * Setup the argtypes array - * ---------- */ argtypes = malloc(sizeof(Oid *) * (expr->nparams + 1)); @@ -1804,9 +1752,8 @@ exec_prepare_plan(PLpgSQL_execstate * estate, } } - /* ---------- + /* * Generate and save the plan - * ---------- */ plan = SPI_prepare(expr->query, expr->nparams, argtypes); if (plan == NULL) @@ -1841,16 +1788,14 @@ exec_stmt_execsql(PLpgSQL_execstate * estate, PLpgSQL_expr *expr = stmt->sqlstmt; bool isnull; - /* ---------- + /* * On the first call for this expression generate the plan - * ---------- */ if (expr->plan == NULL) exec_prepare_plan(estate, expr); - /* ---------- + /* * Now build up the values and nulls arguments for SPI_execp() - * ---------- */ values = palloc(sizeof(Datum) * (expr->nparams + 1)); nulls = palloc(expr->nparams + 1); @@ -1910,9 +1855,8 @@ exec_stmt_execsql(PLpgSQL_execstate * estate, } nulls[i] = '\0'; - /* ---------- + /* * Execute the plan - * ---------- */ rc = SPI_execp(expr->plan, values, nulls, 0); switch (rc) @@ -1956,19 +1900,16 @@ exec_stmt_dynexecute(PLpgSQL_execstate * estate, FmgrInfo finfo_output; int exec_res; - /* ---------- - * First we evaluate the string expression after the - * EXECUTE keyword. It's result is the querystring we have - * to execute. - * ---------- + /* + * First we evaluate the string expression after the EXECUTE keyword. + * It's result is the querystring we have to execute. */ query = exec_eval_expr(estate, stmt->query, &isnull, &restype); if (isnull) elog(ERROR, "cannot EXECUTE NULL query"); - /* ---------- + /* * Get the C-String representation. - * ---------- */ typetup = SearchSysCache(TYPEOID, ObjectIdGetDatum(restype), @@ -1988,11 +1929,10 @@ exec_stmt_dynexecute(PLpgSQL_execstate * estate, ReleaseSysCache(typetup); - /* ---------- - * Call SPI_exec() without preparing a saved plan. - * The returncode can be any standard OK. Note that - * while a SELECT is allowed, its results will be discarded. - * ---------- + /* + * Call SPI_exec() without preparing a saved plan. The returncode can + * be any standard OK. Note that while a SELECT is allowed, its + * results will be discarded. */ exec_res = SPI_exec(querystr, 0); switch (exec_res) @@ -2016,8 +1956,8 @@ exec_stmt_dynexecute(PLpgSQL_execstate * estate, /* * Disallow this for now, because its behavior is not - * consistent with SELECT INTO in a normal plpgsql context. - * We need to reimplement EXECUTE to parse the string as a + * consistent with SELECT INTO in a normal plpgsql context. We + * need to reimplement EXECUTE to parse the string as a * plpgsql command, not just feed it to SPI_exec. */ elog(ERROR, "EXECUTE of SELECT ... INTO is not implemented yet"); @@ -2058,15 +1998,13 @@ exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt) Form_pg_type typeStruct; FmgrInfo finfo_output; - /* ---------- + /* * Initialize the global found variable to false - * ---------- */ exec_set_found(estate, false); - /* ---------- + /* * Determine if we assign to a record or a row - * ---------- */ if (stmt->rec != NULL) rec = (PLpgSQL_rec *) (estate->datums[stmt->rec->recno]); @@ -2078,19 +2016,16 @@ exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt) elog(ERROR, "unsupported target in exec_stmt_fors()"); } - /* ---------- - * Evaluate the string expression after the - * EXECUTE keyword. It's result is the querystring we have - * to execute. - * ---------- + /* + * Evaluate the string expression after the EXECUTE keyword. It's + * result is the querystring we have to execute. */ query = exec_eval_expr(estate, stmt->query, &isnull, &restype); if (isnull) elog(ERROR, "cannot EXECUTE NULL-query"); - /* ---------- + /* * Get the C-String representation. - * ---------- */ typetup = SearchSysCache(TYPEOID, ObjectIdGetDatum(restype), @@ -2110,9 +2045,8 @@ exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt) ReleaseSysCache(typetup); - /* ---------- + /* * Run the query - * ---------- */ if (SPI_exec(querystr, 0) != SPI_OK_SELECT) elog(ERROR, "FOR ... EXECUTE query '%s' was not SELECT", querystr); @@ -2120,10 +2054,9 @@ exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt) n = SPI_processed; - /* ---------- - * If the query didn't return any row, set the target - * to NULL and return. - * ---------- + /* + * If the query didn't return any row, set the target to NULL and + * return. */ if (n == 0) { @@ -2131,36 +2064,32 @@ exec_stmt_dynfors(PLpgSQL_execstate * estate, PLpgSQL_stmt_dynfors * stmt) return PLPGSQL_RC_OK; } - /* ---------- + /* * There are tuples, so set found to true - * ---------- */ exec_set_found(estate, true); - /* ---------- + /* * Now do the loop - * ---------- */ tuptab = SPI_tuptable; SPI_tuptable = NULL; for (i = 0; i < n; i++) { - /* ---------- + + /* * Assign the tuple to the target - * ---------- */ exec_move_row(estate, rec, row, tuptab->vals[i], tuptab->tupdesc); - /* ---------- + /* * Execute the statements - * ---------- */ rc = exec_stmts(estate, stmt->body); - /* ---------- + /* * Check returncode - * ---------- */ switch (rc) { @@ -2236,9 +2165,9 @@ exec_assign_value(PLpgSQL_execstate * estate, switch (target->dtype) { case PLPGSQL_DTYPE_VAR: - /* ---------- + + /* * Target field is a variable - that's easy - * ---------- */ var = (PLpgSQL_var *) target; newvalue = exec_cast_value(value, valtype, var->datatype->typoid, @@ -2255,26 +2184,24 @@ exec_assign_value(PLpgSQL_execstate * estate, break; case PLPGSQL_DTYPE_RECFIELD: - /* ---------- + + /* * Target field is a record - * ---------- */ recfield = (PLpgSQL_recfield *) target; rec = (PLpgSQL_rec *) (estate->datums[recfield->recno]); - /* ---------- - * Check that there is already a tuple in the record. - * We need that because records don't have any predefined - * field structure. - * ---------- + /* + * Check that there is already a tuple in the record. We need + * that because records don't have any predefined field + * structure. */ if (!HeapTupleIsValid(rec->tup)) elog(ERROR, "record %s is unassigned yet - don't know its tuple structure", rec->refname); - /* ---------- + /* * Get the number of the records field to change and the * number of attributes in the tuple. - * ---------- */ fno = SPI_fnumber(rec->tupdesc, recfield->fieldname); if (fno == SPI_ERROR_NOATTRIBUTE) @@ -2282,21 +2209,20 @@ exec_assign_value(PLpgSQL_execstate * estate, fno--; natts = rec->tupdesc->natts; - /* ---------- - * We loop over the attributes of the rec's current tuple - * and collect the values in a Datum array along with the - * nulls information. - * ---------- + /* + * We loop over the attributes of the rec's current tuple and + * collect the values in a Datum array along with the nulls + * information. */ values = palloc(sizeof(Datum) * natts); nulls = palloc(natts + 1); for (i = 0; i < natts; i++) { - /* ---------- + + /* * If this isn't the field we assign to, just use the * value that's already in the tuple. - * ---------- */ if (i != fno) { @@ -2309,10 +2235,9 @@ exec_assign_value(PLpgSQL_execstate * estate, continue; } - /* ---------- - * This is the field to change. Get its type - * and cast the value we insert to that type. - * ---------- + /* + * This is the field to change. Get its type and cast the + * value we insert to that type. */ atttype = SPI_gettypeid(rec->tupdesc, i + 1); atttypmod = rec->tupdesc->attrs[i]->atttypmod; @@ -2336,10 +2261,9 @@ exec_assign_value(PLpgSQL_execstate * estate, ReleaseSysCache(typetup); } - /* ---------- - * Now call heap_formtuple() to create a new tuple - * that replaces the old one in the record. - * ---------- + /* + * Now call heap_formtuple() to create a new tuple that + * replaces the old one in the record. */ nulls[i] = '\0'; rec->tup = heap_formtuple(rec->tupdesc, values, nulls); @@ -2368,17 +2292,15 @@ exec_eval_expr(PLpgSQL_execstate * estate, { int rc; - /* ---------- + /* * If not already done create a plan for this expression - * ---------- */ if (expr->plan == NULL) exec_prepare_plan(estate, expr); - /* ---------- - * If this is a simple expression, bypass SPI and use the - * executor directly - * ---------- + /* + * If this is a simple expression, bypass SPI and use the executor + * directly */ if (expr->plan_simple_expr != NULL) return exec_eval_simple_expr(estate, expr, isNull, rettype); @@ -2387,9 +2309,8 @@ exec_eval_expr(PLpgSQL_execstate * estate, if (rc != SPI_OK_SELECT) elog(ERROR, "query \"%s\" didn't return data", expr->query); - /* ---------- + /* * If there are no rows selected, the result is NULL. - * ---------- */ if (SPI_processed == 0) { @@ -2397,18 +2318,16 @@ exec_eval_expr(PLpgSQL_execstate * estate, return (Datum) 0; } - /* ---------- + /* * Check that the expression returned one single Datum - * ---------- */ if (SPI_processed > 1) elog(ERROR, "query \"%s\" didn't return a single value", expr->query); if (SPI_tuptable->tupdesc->natts != 1) elog(ERROR, "query \"%s\" didn't return a single value", expr->query); - /* ---------- + /* * Return the result and its type - * ---------- */ *rettype = SPI_gettypeid(SPI_tuptable->tupdesc, 1); return SPI_getbinval(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1, isNull); @@ -2436,16 +2355,14 @@ exec_run_select(PLpgSQL_execstate * estate, int fno; bool isnull; - /* ---------- + /* * On the first call for this expression generate the plan - * ---------- */ if (expr->plan == NULL) exec_prepare_plan(estate, expr); - /* ---------- + /* * Now build up the values and nulls arguments for SPI_execp() - * ---------- */ values = palloc(sizeof(Datum) * (expr->nparams + 1)); nulls = palloc(expr->nparams + 1); @@ -2506,9 +2423,8 @@ exec_run_select(PLpgSQL_execstate * estate, } nulls[i] = '\0'; - /* ---------- + /* * Execute the query - * ---------- */ rc = SPI_execp(expr->plan, values, nulls, maxtuples); if (rc != SPI_OK_SELECT) @@ -2544,7 +2460,7 @@ exec_eval_simple_expr(PLpgSQL_execstate * estate, ExprContext *econtext; ParamListInfo paramLI; - /* ---------- + /* * Create a simple expression context to hold the arguments. * * NOTE: we pass TopMemoryContext as the query-lifetime context for @@ -2553,17 +2469,15 @@ exec_eval_simple_expr(PLpgSQL_execstate * estate, * freed in this backend, and the function cache nodes must live as * long as it does). The memory allocation for plpgsql's plan trees * really needs to be redesigned... - * ---------- */ econtext = MakeExprContext(NULL, TopMemoryContext); paramLI = (ParamListInfo) palloc((expr->nparams + 1) * sizeof(ParamListInfoData)); econtext->ecxt_param_list_info = paramLI; - /* ---------- - * Put the parameter values into the parameter list info of - * the expression context. - * ---------- + /* + * Put the parameter values into the parameter list info of the + * expression context. */ for (i = 0; i < expr->nparams; i++, paramLI++) { @@ -2617,15 +2531,13 @@ exec_eval_simple_expr(PLpgSQL_execstate * estate, } paramLI->kind = PARAM_INVALID; - /* ---------- + /* * Initialize things - * ---------- */ *rettype = expr->plan_simple_type; - /* ---------- + /* * Now call the executor to evaluate the expression - * ---------- */ SPI_push(); retval = ExecEvalExprSwitchContext(expr->plan_simple_expr, @@ -2649,9 +2561,8 @@ exec_eval_simple_expr(PLpgSQL_execstate * estate, FreeExprContext(econtext); - /* ---------- + /* * That's it. - * ---------- */ return retval; } @@ -2674,10 +2585,9 @@ exec_move_row(PLpgSQL_execstate * estate, Oid valtype; bool isnull; - /* ---------- - * Record is simple - just put the tuple and its descriptor - * into the record - * ---------- + /* + * Record is simple - just put the tuple and its descriptor into the + * record */ if (rec != NULL) { @@ -2696,10 +2606,9 @@ exec_move_row(PLpgSQL_execstate * estate, } - /* ---------- + /* * Row is a bit more complicated in that we assign the single * attributes of the query to the variables the row points to. - * ---------- */ if (row != NULL) { @@ -2754,10 +2663,10 @@ exec_cast_value(Datum value, Oid valtype, { if (!*isnull) { - /* ---------- - * If the type of the queries return value isn't - * that of the variable, convert it. - * ---------- + + /* + * If the type of the queries return value isn't that of the + * variable, convert it. */ if (valtype != reqtype || reqtypmod != -1) { @@ -2860,19 +2769,17 @@ exec_simple_check_plan(PLpgSQL_expr * expr) expr->plan_simple_expr = NULL; - /* ---------- + /* * 1. We can only evaluate queries that resulted in one single - * execution plan - * ---------- + * execution plan */ if (length(spi_plan->ptlist) != 1) return; plan = (Plan *) lfirst(spi_plan->ptlist); - /* ---------- + /* * 2. It must be a RESULT plan --> no scan's required - * ---------- */ if (plan == NULL) /* utility statement produces this */ return; @@ -2880,9 +2787,8 @@ exec_simple_check_plan(PLpgSQL_expr * expr) if (!IsA(plan, Result)) return; - /* ---------- + /* * 3. Can't have any subplan or qual clause, either - * ---------- */ if (plan->lefttree != NULL || plan->righttree != NULL || @@ -2892,27 +2798,24 @@ exec_simple_check_plan(PLpgSQL_expr * expr) ((Result *) plan)->resconstantqual != NULL) return; - /* ---------- + /* * 4. The plan must have a single attribute as result - * ---------- */ if (length(plan->targetlist) != 1) return; tle = (TargetEntry *) lfirst(plan->targetlist); - /* ---------- - * 5. Check that all the nodes in the expression are one of - * Expr, Param or Const. - * ---------- + /* + * 5. Check that all the nodes in the expression are one of Expr, + * Param or Const. */ if (!exec_simple_check_node(tle->expr)) return; - /* ---------- - * Yes - this is a simple expression. Remember the expression - * and the return type - * ---------- + /* + * Yes - this is a simple expression. Remember the expression and the + * return type */ expr->plan_simple_expr = tle->expr; expr->plan_simple_type = exprType(tle->expr); diff --git a/src/pl/plpgsql/src/pl_funcs.c b/src/pl/plpgsql/src/pl_funcs.c index ac069fec4a5..13fd9673767 100644 --- a/src/pl/plpgsql/src/pl_funcs.c +++ b/src/pl/plpgsql/src/pl_funcs.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.11 2001/03/22 04:01:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.12 2001/03/22 06:16:21 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -224,9 +224,8 @@ plpgsql_ns_lookup(char *name, char *label) PLpgSQL_ns *ns; int i; - /* ---------- + /* * If a label is specified, lookup only in that - * ---------- */ if (label != NULL) { @@ -245,9 +244,8 @@ plpgsql_ns_lookup(char *name, char *label) return NULL; /* label not found */ } - /* ---------- + /* * No label given, lookup for visible labels ignoring localmode - * ---------- */ for (ns = ns_current; ns != NULL; ns = ns->upper) { @@ -255,9 +253,8 @@ plpgsql_ns_lookup(char *name, char *label) return ns->items[0]; } - /* ---------- + /* * Finally lookup name in the namestack - * ---------- */ for (ns = ns_current; ns != NULL; ns = ns->upper) { @@ -287,13 +284,12 @@ plpgsql_ns_rename(char *oldname, char *newname) PLpgSQL_nsitem *newitem; int i; - /* ---------- + /* * Lookup in the current namespace only - * ---------- */ - /* ---------- + + /* * Lookup name in the namestack - * ---------- */ for (ns = ns_current; ns != NULL; ns = ns->upper) { diff --git a/src/pl/plpgsql/src/pl_handler.c b/src/pl/plpgsql/src/pl_handler.c index ee6542f608f..8801ce55e37 100644 --- a/src/pl/plpgsql/src/pl_handler.c +++ b/src/pl/plpgsql/src/pl_handler.c @@ -3,7 +3,7 @@ * procedural language * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.7 2001/03/22 04:01:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_handler.c,v 1.8 2001/03/22 06:16:21 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -75,24 +75,22 @@ plpgsql_call_handler(PG_FUNCTION_ARGS) PLpgSQL_function *func; Datum retval; - /* ---------- + /* * Connect to SPI manager - * ---------- */ if (SPI_connect() != SPI_OK_CONNECT) elog(ERROR, "plpgsql: cannot connect to SPI manager"); - /* ---------- + /* * Check if we already compiled this function and saved the pointer * (ie, current FmgrInfo has been used before) - * ---------- */ func = (PLpgSQL_function *) fcinfo->flinfo->fn_extra; if (func == NULL) { - /* ---------- + + /* * Check if we already compiled this function - * ---------- */ Oid funcOid = fcinfo->flinfo->fn_oid; @@ -102,9 +100,8 @@ plpgsql_call_handler(PG_FUNCTION_ARGS) break; } - /* ---------- + /* * If not, do so and add it to the compiled ones - * ---------- */ if (func == NULL) { @@ -114,17 +111,15 @@ plpgsql_call_handler(PG_FUNCTION_ARGS) compiled_functions = func; } - /* ---------- + /* * Save pointer in FmgrInfo to avoid search on subsequent calls - * ---------- */ fcinfo->flinfo->fn_extra = (void *) func; } - /* ---------- - * Determine if called as function or trigger and - * call appropriate subhandler - * ---------- + /* + * Determine if called as function or trigger and call appropriate + * subhandler */ if (isTrigger) retval = PointerGetDatum(plpgsql_exec_trigger(func, @@ -132,9 +127,8 @@ plpgsql_call_handler(PG_FUNCTION_ARGS) else retval = plpgsql_exec_function(func, fcinfo); - /* ---------- + /* * Disconnect from SPI manager - * ---------- */ if (SPI_finish() != SPI_OK_FINISH) elog(ERROR, "plpgsql: SPI_finish() failed"); |
