Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0f23ded

Browse files
committed
Print out error position for some more DDLs
The following commands gain some information about the error position in the query, should they fail when looking at the type used: - CREATE TYPE (LIKE) - CREATE TABLE OF Both are related to typenameType() where the type name lookup is done. These calls gain the ParseState that already exists in these paths. Author: Kirill Reshke, Jian He Reviewed-by: Álvaro Herrera, Michael Paquier Discussion: https://postgr.es/m/CALdSSPhqfvKbDwqJaY=yEePi_aq61GmMpW88i6ZH7CMG_2Z4Cg@mail.gmail.com
1 parent e116b70 commit 0f23ded

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

src/backend/commands/typecmds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ DefineType(ParseState *pstate, List *names, List *parameters)
348348
Type likeType;
349349
Form_pg_type likeForm;
350350

351-
likeType = typenameType(NULL, defGetTypeName(likeTypeEl), NULL);
351+
likeType = typenameType(pstate, defGetTypeName(likeTypeEl), NULL);
352352
likeForm = (Form_pg_type) GETSTRUCT(likeType);
353353
internalLength = likeForm->typlen;
354354
byValue = likeForm->typbyval;

src/backend/parser/parse_utilcmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
16151615

16161616
Assert(ofTypename);
16171617

1618-
tuple = typenameType(NULL, ofTypename, NULL);
1618+
tuple = typenameType(cxt->pstate, ofTypename, NULL);
16191619
check_of_type(tuple);
16201620
ofTypeId = ((Form_pg_type) GETSTRUCT(tuple))->oid;
16211621
ofTypename->typeOid = ofTypeId; /* cached for later */

src/test/regress/expected/float8.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,8 @@ LINE 1: create function xfloat8out(xfloat8) returns cstring immutabl...
10261026
^
10271027
create type xfloat8 (input = xfloat8in, output = xfloat8out, like = no_such_type);
10281028
ERROR: type "no_such_type" does not exist
1029+
LINE 1: ...8 (input = xfloat8in, output = xfloat8out, like = no_such_ty...
1030+
^
10291031
create type xfloat8 (input = xfloat8in, output = xfloat8out, like = float8);
10301032
create cast (xfloat8 as float8) without function;
10311033
create cast (float8 as xfloat8) without function;

src/test/regress/expected/typed_table.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
CREATE TABLE ttable1 OF nothing;
22
ERROR: type "nothing" does not exist
3+
LINE 1: CREATE TABLE ttable1 OF nothing;
4+
^
35
CREATE TYPE person_type AS (id int, name text);
46
CREATE TABLE persons OF person_type;
57
CREATE TABLE IF NOT EXISTS persons OF person_type;

0 commit comments

Comments
 (0)