Skip to content

Commit 8f83dc5

Browse files
committed
SQL: extract types in Postgresql input
Signed-off-by: Masatake YAMATO <[email protected]>
1 parent 8af995c commit 8f83dc5

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
--sort=no
22
--fields=+S
33
--extras=+g
4+
--kinds-SQL=+r

Units/parser-sql.r/funcions.d/expected.tags

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
evr_array_item input.sql /^create type evr_array_item as ($/;" r
2+
n input.sql /^ n NUMERIC,$/;" E record:evr_array_item
3+
s input.sql /^ s TEXT$/;" E record:evr_array_item
4+
evr_t input.sql /^create type evr_t as ($/;" r
5+
epoch input.sql /^ epoch INT,$/;" E record:evr_t
6+
version input.sql /^ version evr_array_item[],$/;" E record:evr_t
7+
release input.sql /^ release evr_array_item[]$/;" E record:evr_t
18
evr_trigger input.sql /^CREATE FUNCTION evr_trigger() RETURNS trigger AS $\$$/;" f typeref:typename:trigger signature:()
29
empty input.sql /^create or replace FUNCTION empty(t TEXT)$/;" f typeref:typename:BOOLEAN signature:(t TEXT)
310
isalpha input.sql /^create or replace FUNCTION isalpha(ch CHAR)$/;" f typeref:typename:BOOLEAN signature:(ch CHAR)

parsers/sql.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,8 +1718,11 @@ static void parseType (tokenInfo *const token)
17181718
if (isKeyword (token, KEYWORD_is))
17191719
{
17201720
readToken (token);
1721-
switch (token->keyword)
1721+
1722+
if (isType (token, TOKEN_KEYWORD))
17221723
{
1724+
switch (token->keyword)
1725+
{
17231726
case KEYWORD_record:
17241727
case KEYWORD_object:
17251728
makeSqlTag (name, SQLTAG_RECORD);
@@ -1738,6 +1741,14 @@ static void parseType (tokenInfo *const token)
17381741
break;
17391742

17401743
default: break;
1744+
/* TODO: PostgreSQL can take 'enum (' and 'range (' here. */
1745+
}
1746+
}
1747+
else if (isType (token, TOKEN_OPEN_PAREN))
1748+
{
1749+
makeSqlTag (name, SQLTAG_RECORD);
1750+
addToScope (token, name->string, SQLTAG_RECORD);
1751+
parseRecord (token);
17411752
}
17421753
vStringClear (token->scope);
17431754
token->scopeKind = SQLTAG_COUNT;

0 commit comments

Comments
 (0)