Repository: sqlfluff/sqlfluff

Issue:
Postgres dialect seems to be missing some keywords
I believe there are some keywords missing in the Postgres dialect. For example, based on this [list](https://www.postgresql.org/docs/current/sql-keywords-appendix.html), `CURRENT_DATE` should be considered a reserved keyword. However, the [ansi keywords](https://github.com/sqlfluff/sqlfluff/blob/b195e2585483fa220d88ced6c8ec271d08919170/src/sqlfluff/dialects/ansi_keywords.py) and the [postgres dialect](https://github.com/sqlfluff/sqlfluff/blob/b195e2585483fa220d88ced6c8ec271d08919170/src/sqlfluff/dialects/dialect_postgres.py#L39-L55) code don't include it. There may be other reserved words in that list that are missing (`CURRENT_TIME`, etc)

## Steps to Reproduce
```
DATEADD(day, -2, current_date)
```

## Expected Behaviour
```
DATEADD(day, -2, CURRENT_DATE)
```

## Observed Behaviour
```
DATEADD(day, -2, current_date)
```

## Dialect
postgres

## Version
sqlfluff, version 0.6.4
Python 3.7.11

## Configuration
```
[sqlfluff]
nocolor = True
dialect = postgres
templater = dbt
output_line_length = 120
ignore = parsing, templating

[sqlfluff:rules]
comma_style = leading
max_line_length = 120
tab_space_size = 2

[sqlfluff:rules:L010]  # Keywords
capitalisation_policy = upper

[sqlfluff:rules:L014]  # Unquoted Identifiers
extended_capitalisation_policy = lower

[sqlfluff:rules:L030]  # Function names
capitalisation_policy = upper

[sqlfluff:rules:L040]  # Null & Boolean Literals
capitalisation_policy = upper
```


Discussion:
WittierDinosaur: I have absolutely no idea... no files have been removed on this PR
tunetheweb: > I have absolutely no idea... no files have been removed on this PR

Hmmm see this:

![image](https://user-images.githubusercontent.com/10931297/132213459-70ef8786-1a08-4069-a932-95939010d111.png)

@alanmcruickshank / @sqlfluff/sqlfluff-maintainers any ideas?
barrywhart: I haven't seen this CircleCI issue. Possible it's a short term breakage on their side? Or a change in behavior? E.g. the file needs to be in a different place now?
tunetheweb: Did you see my last update @barrywhart ? Looks like we've been suspended from CircleCI 😱
tunetheweb: CircleCI is back!
codecov[bot]: # [Codecov](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1360?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff) Report
> Merging [#1360](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1360?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff) (b0c4167) into [main](https://codecov.io/gh/sqlfluff/sqlfluff/commit/7bb7ffc487ffe31f3e0cd748d75fa1242ef98bb1?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff) (7bb7ffc) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1360/graphs/tree.svg?width=650&height=150&src=pr&token=maM8kLgCmn&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff)](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1360?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff)

```diff
@@            Coverage Diff            @@
##              main     #1360   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          125       125           
  Lines         8374      8376    +2     
=========================================
+ Hits          8374      8376    +2     
```

| Flag | Coverage Δ | |
|---|---|---|
| dbt018-py38 | `62.20% <20.00%> (-0.02%)` | :arrow_down: |
| dbt019-py38 | `62.20% <20.00%> (-0.02%)` | :arrow_down: |
| dbt020-py38 | `62.18% <20.00%> (-0.02%)` | :arrow_down: |
| py36 | `98.92% <100.00%> (+<0.01%)` | :arrow_up: |
| py37 | `98.96% <100.00%> (+<0.01%)` | :arrow_up: |
| py38 | `?` | |
| py39 | `98.97% <100.00%> (+<0.01%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1360?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff) | Coverage Δ | |
|---|---|---|
| [src/sqlfluff/rules/L030.py](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1360/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff#diff-c3JjL3NxbGZsdWZmL3J1bGVzL0wwMzAucHk=) | `100.00% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1360?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1360?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff). Last update [7bb7ffc...b0c4167](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1360?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff).


Patch:
diff --git a/src/sqlfluff/rules/L030.py b/src/sqlfluff/rules/L030.py
index e0702a990..1c1ff765f 100644
--- a/src/sqlfluff/rules/L030.py
+++ b/src/sqlfluff/rules/L030.py
@@ -39,7 +39,10 @@ class Rule_L030(Rule_L010):
 
     """
 
-    _target_elems: List[Tuple[str, str]] = [("type", "function_name")]
+    _target_elems: List[Tuple[str, str]] = [
+        ("type", "function_name"),
+        ("type", "bare_function"),
+    ]
     _description_elem = "Function names"
 
     def _get_fix(self, segment, fixed_raw):
@@ -48,13 +51,17 @@ class Rule_L030(Rule_L010):
         We need to do this because function_name nodes have a child
         function_name_identifier that holds the actual name.
         """
-        child_segment = [
-            child
-            for child in segment.segments
-            if child.get_type() == "function_name_identifier"
-        ][0]
-        return LintFix(
-            "edit",
-            child_segment,
-            child_segment.edit(fixed_raw.strip()),
-        )
+        if segment.type == "function_name":
+
+            child_segment = [
+                child
+                for child in segment.segments
+                if child.get_type() == "function_name_identifier"
+            ][0]
+            return LintFix(
+                "edit",
+                child_segment,
+                child_segment.edit(fixed_raw.strip()),
+            )
+
+        return super()._get_fix(segment, fixed_raw)


Test patch:
diff --git a/test/fixtures/rules/std_rule_cases/L030.yml b/test/fixtures/rules/std_rule_cases/L030.yml
index 62f4364c1..aad35080d 100644
--- a/test/fixtures/rules/std_rule_cases/L030.yml
+++ b/test/fixtures/rules/std_rule_cases/L030.yml
@@ -16,6 +16,26 @@ test_2:
       L030:
         capitalisation_policy: lower
 
+test_bare_functions:
+  fail_str: SELECT current_timestamp from table
+
+  fix_str: SELECT CURRENT_TIMESTAMP from table
+
+  configs:
+    rules:
+      L030:
+        capitalisation_policy: upper
+
+test_bare_functions_2:
+  fail_str: SELECT current_timestamp, min(a) from table
+
+  fix_str: SELECT CURRENT_TIMESTAMP, MIN(a) from table
+
+  configs:
+    rules:
+      L030:
+        capitalisation_policy: upper
+
 test_fail_capitalization_after_comma:
   fail_str: SELECT FLOOR(dt) ,count(*) FROM test
   fix_str: SELECT FLOOR(dt) ,COUNT(*) FROM test