summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier2024-12-17 00:44:06 +0000
committerMichael Paquier2024-12-17 00:44:06 +0000
commit0f23dedc91760271aefe9e3c52d677c079bb7bce (patch)
tree1683d309c43ffcca01170c359a5394369dbad257
parente116b703f0b9b551cb413c8f2cfe231a9ce73f42 (diff)
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
-rw-r--r--src/backend/commands/typecmds.c2
-rw-r--r--src/backend/parser/parse_utilcmd.c2
-rw-r--r--src/test/regress/expected/float8.out2
-rw-r--r--src/test/regress/expected/typed_table.out2
4 files changed, 6 insertions, 2 deletions
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index 6127313956..4f20b5be06 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -348,7 +348,7 @@ DefineType(ParseState *pstate, List *names, List *parameters)
Type likeType;
Form_pg_type likeForm;
- likeType = typenameType(NULL, defGetTypeName(likeTypeEl), NULL);
+ likeType = typenameType(pstate, defGetTypeName(likeTypeEl), NULL);
likeForm = (Form_pg_type) GETSTRUCT(likeType);
internalLength = likeForm->typlen;
byValue = likeForm->typbyval;
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index 0f324ee4e3..95dad76683 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -1615,7 +1615,7 @@ transformOfType(CreateStmtContext *cxt, TypeName *ofTypename)
Assert(ofTypename);
- tuple = typenameType(NULL, ofTypename, NULL);
+ tuple = typenameType(cxt->pstate, ofTypename, NULL);
check_of_type(tuple);
ofTypeId = ((Form_pg_type) GETSTRUCT(tuple))->oid;
ofTypename->typeOid = ofTypeId; /* cached for later */
diff --git a/src/test/regress/expected/float8.out b/src/test/regress/expected/float8.out
index 4965ee5554..9ef9793fe9 100644
--- a/src/test/regress/expected/float8.out
+++ b/src/test/regress/expected/float8.out
@@ -1026,6 +1026,8 @@ LINE 1: create function xfloat8out(xfloat8) returns cstring immutabl...
^
create type xfloat8 (input = xfloat8in, output = xfloat8out, like = no_such_type);
ERROR: type "no_such_type" does not exist
+LINE 1: ...8 (input = xfloat8in, output = xfloat8out, like = no_such_ty...
+ ^
create type xfloat8 (input = xfloat8in, output = xfloat8out, like = float8);
create cast (xfloat8 as float8) without function;
create cast (float8 as xfloat8) without function;
diff --git a/src/test/regress/expected/typed_table.out b/src/test/regress/expected/typed_table.out
index b6fbda3f21..aa6150b853 100644
--- a/src/test/regress/expected/typed_table.out
+++ b/src/test/regress/expected/typed_table.out
@@ -1,5 +1,7 @@
CREATE TABLE ttable1 OF nothing;
ERROR: type "nothing" does not exist
+LINE 1: CREATE TABLE ttable1 OF nothing;
+ ^
CREATE TYPE person_type AS (id int, name text);
CREATE TABLE persons OF person_type;
CREATE TABLE IF NOT EXISTS persons OF person_type;