diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pl/plpgsql/src/gram.y | 26 | ||||
-rw-r--r-- | src/pl/plpgsql/src/pl_funcs.c | 44 | ||||
-rw-r--r-- | src/pl/plpgsql/src/plpgsql.h | 5 | ||||
-rw-r--r-- | src/pl/plpgsql/src/scan.l | 3 | ||||
-rw-r--r-- | src/test/regress/expected/plpgsql.out | 2 | ||||
-rw-r--r-- | src/test/regress/sql/plpgsql.sql | 2 |
6 files changed, 10 insertions, 72 deletions
diff --git a/src/pl/plpgsql/src/gram.y b/src/pl/plpgsql/src/gram.y index ec6b285bf2f..e2e3f203ae0 100644 --- a/src/pl/plpgsql/src/gram.y +++ b/src/pl/plpgsql/src/gram.y @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.129 2009/11/04 22:26:07 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.130 2009/11/05 16:58:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -128,7 +128,6 @@ static List *read_raise_options(void); %type <declhdr> decl_sect %type <varname> decl_varname -%type <str> decl_renname %type <boolean> decl_const decl_notnull exit_type %type <expr> decl_defval decl_cursor_query %type <dtype> decl_datatype @@ -218,7 +217,6 @@ static List *read_raise_options(void); %token K_PERFORM %token K_ROW_COUNT %token K_RAISE -%token K_RENAME %token K_RESULT_OID %token K_RETURN %token K_REVERSE @@ -382,10 +380,6 @@ decl_statement : decl_varname decl_const decl_datatype decl_notnull decl_defval plpgsql_ns_additem($4->itemtype, $4->itemno, $1.name); } - | K_RENAME decl_renname K_TO decl_renname ';' - { - plpgsql_ns_rename($2, $4); - } | decl_varname opt_scrollable K_CURSOR { plpgsql_ns_push($1.name); } decl_cursor_args decl_is_for decl_cursor_query @@ -521,9 +515,8 @@ decl_aliasitem : any_identifier char *name; PLpgSQL_nsitem *nsi; + /* XXX should allow block-label-qualified names */ plpgsql_convert_ident($1, &name, 1); - if (name[0] != '$') - yyerror("only positional parameters can be aliased"); plpgsql_ns_setlocal(false); @@ -532,8 +525,8 @@ decl_aliasitem : any_identifier { plpgsql_error_lineno = plpgsql_scanner_lineno(); ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_PARAMETER), - errmsg("function has no parameter \"%s\"", + (errcode(ERRCODE_UNDEFINED_OBJECT), + errmsg("variable \"%s\" does not exist", name))); } @@ -573,17 +566,6 @@ decl_varname : T_WORD } ; -/* XXX this is broken because it doesn't allow for T_SCALAR,T_ROW,T_RECORD */ -decl_renname : T_WORD - { - char *name; - - plpgsql_convert_ident(yytext, &name, 1); - /* the result must be palloc'd, see plpgsql_ns_rename */ - $$ = name; - } - ; - decl_const : { $$ = false; } | K_CONSTANT diff --git a/src/pl/plpgsql/src/pl_funcs.c b/src/pl/plpgsql/src/pl_funcs.c index 274d0271141..790e2e86bac 100644 --- a/src/pl/plpgsql/src/pl_funcs.c +++ b/src/pl/plpgsql/src/pl_funcs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.82 2009/11/04 22:26:07 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.83 2009/11/05 16:58:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -236,48 +236,6 @@ plpgsql_ns_lookup_label(const char *name) /* ---------- - * plpgsql_ns_rename Rename a namespace entry - * ---------- - */ -void -plpgsql_ns_rename(char *oldname, char *newname) -{ - PLpgSQL_ns *ns; - PLpgSQL_nsitem *newitem; - int i; - - /* - * Lookup name in the namestack - */ - for (ns = ns_current; ns != NULL; ns = ns->upper) - { - for (i = 1; i < ns->items_used; i++) - { - if (strcmp(ns->items[i]->name, oldname) == 0) - { - newitem = palloc(sizeof(PLpgSQL_nsitem) + strlen(newname)); - newitem->itemtype = ns->items[i]->itemtype; - newitem->itemno = ns->items[i]->itemno; - strcpy(newitem->name, newname); - - pfree(oldname); - pfree(newname); - - pfree(ns->items[i]); - ns->items[i] = newitem; - return; - } - } - } - - ereport(ERROR, - (errcode(ERRCODE_UNDEFINED_OBJECT), - errmsg("variable \"%s\" does not exist in the current block", - oldname))); -} - - -/* ---------- * plpgsql_convert_ident * * Convert a possibly-qualified identifier to internal form: handle diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h index 3d0f155a884..193d8d5c4c6 100644 --- a/src/pl/plpgsql/src/plpgsql.h +++ b/src/pl/plpgsql/src/plpgsql.h @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.118 2009/11/04 22:26:07 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.119 2009/11/05 16:58:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -287,7 +287,7 @@ typedef struct { /* Item in the compilers namestack */ int itemtype; int itemno; - char name[1]; + char name[1]; /* actually, as long as needed */ } PLpgSQL_nsitem; @@ -851,7 +851,6 @@ extern void plpgsql_ns_additem(int itemtype, int itemno, const char *name); extern PLpgSQL_nsitem *plpgsql_ns_lookup(const char *name1, const char *name2, const char *name3, int *names_used); extern PLpgSQL_nsitem *plpgsql_ns_lookup_label(const char *name); -extern void plpgsql_ns_rename(char *oldname, char *newname); /* ---------- * Other functions in pl_funcs.c diff --git a/src/pl/plpgsql/src/scan.l b/src/pl/plpgsql/src/scan.l index b309d811872..3563b2ff154 100644 --- a/src/pl/plpgsql/src/scan.l +++ b/src/pl/plpgsql/src/scan.l @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.72 2009/09/29 20:05:29 tgl Exp $ + * $PostgreSQL: pgsql/src/pl/plpgsql/src/scan.l,v 1.73 2009/11/05 16:58:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -183,7 +183,6 @@ open { return K_OPEN; } or { return K_OR; } perform { return K_PERFORM; } raise { return K_RAISE; } -rename { return K_RENAME; } result_oid { return K_RESULT_OID; } return { return K_RETURN; } reverse { return K_REVERSE; } diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out index e3cacf589ec..2e97bec42e9 100644 --- a/src/test/regress/expected/plpgsql.out +++ b/src/test/regress/expected/plpgsql.out @@ -162,7 +162,7 @@ create trigger tg_pfield_ad after delete create function tg_pslot_biu() returns trigger as $proc$ declare pfrec record; - rename new to ps; + ps alias for new; begin select into pfrec * from PField where name = ps.pfname; if not found then diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql index 3e6b6de539e..83cda97d1bf 100644 --- a/src/test/regress/sql/plpgsql.sql +++ b/src/test/regress/sql/plpgsql.sql @@ -211,7 +211,7 @@ create trigger tg_pfield_ad after delete create function tg_pslot_biu() returns trigger as $proc$ declare pfrec record; - rename new to ps; + ps alias for new; begin select into pfrec * from PField where name = ps.pfname; if not found then |