Skip to content

Commit af013a5

Browse files
committed
SQL: make foreign tags for 'interenal' functions
Signed-off-by: Masatake YAMATO <[email protected]>
1 parent 6e4b061 commit af013a5

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
--sort=no
2+
--fields=+lSr
3+
--extras=+r
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
isnlt input.sql /^CREATE FUNCTION isnlt(ean13, ean13)$/;" f language:SQL typeref:typename:boolean signature:(ean13, ean13) roles:def
2+
int8lt input.sql /^ AS 'int8lt'$/;" f language:C roles:foreigncall
3+
isnle input.sql /^CREATE FUNCTION isnle(ean13, ean13)$/;" f language:SQL typeref:typename:boolean signature:(ean13, ean13) roles:def
4+
int8le input.sql /^ AS 'int8le'$/;" f language:C roles:foreigncall
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CREATE FUNCTION isnlt(ean13, ean13)
2+
RETURNS boolean
3+
AS 'int8lt'
4+
LANGUAGE 'internal'
5+
IMMUTABLE STRICT
6+
PARALLEL SAFE;
7+
CREATE FUNCTION isnle(ean13, ean13)
8+
RETURNS boolean
9+
AS 'int8le'
10+
LANGUAGE 'internal'
11+
IMMUTABLE STRICT
12+
PARALLEL SAFE;

parsers/sql.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
#include "xtag.h"
3131
#include "promise.h"
3232

33+
#include "dependency.h"
34+
#include "cxx/cxx_tag.h"
35+
3336
/*
3437
* On-line "Oracle Database PL/SQL Language Reference":
3538
* http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/toc.htm
@@ -505,6 +508,8 @@ static struct SqlReservedWord SqlReservedWord [SQLKEYWORD_COUNT] = {
505508
[KEYWORD_without] = {0 & 0&1&1&0 & 0&0 & 0},
506509
};
507510

511+
static langType Lang_c;
512+
508513
/*
509514
* FUNCTION DECLARATIONS
510515
*/
@@ -2207,6 +2212,16 @@ static void parseBlock (tokenInfo *const token, const bool local)
22072212
parseBlockFull (token, local, LANG_IGNORE);
22082213
}
22092214

2215+
static void makeSqlTagForInternalFunction (tokenInfo *const token)
2216+
{
2217+
tagEntryInfo foreignEntry;
2218+
initForeignRefTagEntry (
2219+
&foreignEntry, vStringValue (token->string), Lang_c,
2220+
CXXTagKindFUNCTION, CXXTagFUNCTIONRoleFOREIGNCALL);
2221+
updateTagLine (&foreignEntry, token->lineNumber, token->filePosition);
2222+
makeTagEntry (&foreignEntry);
2223+
}
2224+
22102225
static void parseBlockFull (tokenInfo *const token, const bool local, langType lang)
22112226
{
22122227
int promise = -1;
@@ -2226,6 +2241,9 @@ static void parseBlockFull (tokenInfo *const token, const bool local, langType l
22262241
promise = token->promise;
22272242
token->promise = -1;
22282243

2244+
tokenInfo *const body = newToken ();
2245+
copyToken (body, token);
2246+
22292247
readToken (token);
22302248
while (! isCmdTerm (token)
22312249
&& !isType (token, TOKEN_EOF))
@@ -2237,10 +2255,16 @@ static void parseBlockFull (tokenInfo *const token, const bool local, langType l
22372255
lang = getNamedLanguageFromToken (token);
22382256
if (lang != LANG_IGNORE)
22392257
readToken (token);
2258+
else if (vStringEqC (token->string, "internal"))
2259+
{
2260+
makeSqlTagForInternalFunction (body);
2261+
readToken (token);
2262+
}
22402263
}
22412264
else
22422265
readToken (token);
22432266
}
2267+
deleteToken (body);
22442268

22452269
if (promise != -1 && lang != LANG_IGNORE)
22462270
promiseUpdateLanguage(promise, lang);
@@ -3388,6 +3412,10 @@ extern parserDefinition* SqlParser (void)
33883412
static const char *const extensions [] = { "sql", NULL };
33893413
static const char *const aliases [] = {"pgsql", NULL };
33903414
parserDefinition* def = parserNew ("SQL");
3415+
static parserDependency dependencies [] = {
3416+
[0] = { DEPTYPE_FOREIGNER, "C", &Lang_c },
3417+
};
3418+
33913419
def->kindTable = SqlKinds;
33923420
def->kindCount = ARRAY_SIZE (SqlKinds);
33933421
def->extensions = extensions;
@@ -3397,5 +3425,7 @@ extern parserDefinition* SqlParser (void)
33973425
def->keywordTable = SqlKeywordTable;
33983426
def->keywordCount = ARRAY_SIZE (SqlKeywordTable);
33993427
def->useCork = CORK_QUEUE | CORK_SYMTAB;
3428+
def->dependencies = dependencies;
3429+
def->dependencyCount = ARRAY_SIZE (dependencies);
34003430
return def;
34013431
}

0 commit comments

Comments
 (0)