Commit Graph

32 Commits (4152a391c2f4e216fe69f576d895638a7626b975)

Author SHA1 Message Date
Onur Tirtir 4152a391c2
Properly set col names for shard rels that citus_extradata_container points to (#6428)
Deparser function set_relation_column_names() knows that it needs to
re-evaluate column names based on relation's tuple descriptor when
the rte belongs to a relation (RTE_RELATION).

However before this commit, it didn't know about the fact that citus
might wrap such an rte with an rte that points to
citus_extradata_container() placeholder.

And because of this, it was simply taking the column aliases
(e.g., "bar" in "foo AS bar") into the account and this might result in
an incorrectly deparsed query as in below case:

* Say, if we had view based on following query:
  ```sql
  SELECT a FROM table;
  ```
* And if we rename column "a" to "b", the view query normally becomes:
  ```sql
  SELECT b AS a FROM table;
  ```
* So before this commit, deparsing a query based on that view was
resulting in such a query due to deparsing based on the column aliases,
  which is not correct:
  ```sql
  SELECT a FROM table;
  ```

Fixes #5932.

DESCRIPTION: Fixes a bug that might cause failing to query the views
based on tables that have renamed columns
2022-10-14 17:31:25 +03:00
Naisila Puka 27e867afbc
Propagates column aliases (#6400)
Propagates column aliases in the shard-level commands
2022-10-06 12:27:31 +03:00
Naisila Puka 35b4ddc355
Pg15 support (#6085)
* Adjust configure script to allow PG15

* Adds copy of ruleutils_14.c as ruleutils_15.c

* Uses get_namespace_name_or_temp in ruleutils_15.c

Relevant PG commit:
48c5c9068211e0a04fd9553c8714b2821ed3ad17

* Clean up code using "(expr) ? true : false" in ruleutils_15.c

Relevant PG commit:
fd0625c7a9c679c0c1e896014b8f49a489c3a245

* Change varno from Index (unsigned int) to int in ruleutils_15.c

Relevant PG commit:
e3ec3c00d85bd2844ffddee83df2bd67c4f8297f

* Adds find_recursive_union to ruleutils_15.c

Relevant PG commit:
3f50b82639637c9908afa2087de7588450aa866b

* Fix display of SQL-std func's args in INSERT/SELECT in ruleutils_15.c

Relevant PG commit:
a8d8445a7b2f80f6d0bfe97b19f90bd2cbef8759

* Fix ruleutils_15.c's dumping of whole-row Vars in more contexts

Relevant PG commit:
43c2175121c829c8591fc5117b725f1f22bfb670

* Fix assorted missing logic for GroupingFunc nodes in ruleutils_15.c

Relevant PG commit:
2591ee8ec44d8cbc8e1226550337a64c684746e4

* Adds grammar support for SQL/JSON clauses in ruleutils_15.c

Relevant PG commit:
f79b803dcc98d707450e158db3638dc67ff8380b

* Adds SQL/JSON constructors to ruleutils_15.c

Relevant PG commits:
f4fb45d15c59d7add2e1b81a9d477d0119a9691a
cc7401d5ca498a84d9b47fd2e01cebd8e830e558

* Adds support for MERGE in ruleutils_15.c

Relevant PG commit:
7103ebb7aae8ab8076b7e85f335ceb8fe799097c

* Add IS JSON predicate to ruleutils_15.c

Relevant PG commit:
33a377608fc29cdd1f6b63be561eab0aee5c81f0

* Add SQL/JSON query functions to ruleutils_15.c

Relevant PG commit:
1a36bc9dba8eae90963a586d37b6457b32b2fed4

* Adds three different SQL/JSON values to ruleutils_15.c

Relevant PG commits:
606948b058dc16bce494270eea577011a602810e
49082c2cc3d8167cca70cfe697afb064710828ca

* Adds JSON table functions in ruleutils_15.c

Relevant PG commit:
4e34747c88a03ede6e9d731727815e37273d4bc9

* Add PLAN function for JSON table in ruleutils_15.c

Relevant PG commit:
fadb48b00e02ccfd152baa80942de30205ab3c4f

* Remove extra blank lines before block-closing braces ruleutils_15.c

Relevant PG commit:
24d2b2680a8d0e01b30ce8a41c4eb3b47aca5031

* set_deparse_plan: Reuse variable to appease Coverity ruleutils_15.c

Relevant PG commit:
e70813fbc4aaca35ec012d5a426706bd54e4acab

* Mechanical code beautification ruleutils_15.c

Relevant PG commit:
23e7b38bfe396f919fdb66057174d29e17086418

* Rename value_type to item_type in ruleutils_15.c

Relevant PG commit:
3ab9a63cb638a1fd99475668e2da9c237495aeda

* Show 'AS "?column?"' explicitly when it's important in ruleutils_15.c

Relevant PG commit:
c7461fc25558832dd347a9c8150b0f1ed85e36e8

* Fix ruleutils_15.c issues with dropped cols in funcs-returning-composite

Relevant PG commit:
c1d1e8469c77ce6b8e5310955580b4a3eee7fe96

* Change comment regarding functions returning composite in ruleutils_15.c

Relevant PG commit:
c2fa113ddb1117b1f03e91960f65d5d7d8a90270

* Replace int nodes with bool nodes where needed

In PG15, Boolean nodes are added. Pre PG15, internal Boolean values
in Create Role commands were represented by Integer nodes. This
commit replaces int nodes logic with bool nodes logic where needed.
Mostly there are CREATE ROLE logic changes.

Relevant PG commit:
941460fcf731a32e6a90691508d5cfa3d1f8eeaf

* Handle new option colliculocale in CREATE COLLATION logic

In PG15, there is an added option to use ICU as global locale provider.
pg_collation has three locale-related fields: collcollate and collctype,
which are libc-related fields, and a new one colliculocale, which is the
ICU-related field. Only the libc-related fields or the ICU-related field
is set, never both.

Relevant PG commits:
f2553d43060edb210b36c63187d52a632448e1d2
54637508f87bd5f07fb9406bac6b08240283be3b

* Add PG15 tests to CI using test images that have 15beta2 (#6093)

* Change warning message in pg_signal_backend()

Relevant PG commit:
7fa945b857cc1b2964799411f1633468826861ff

* Revert "Add missing ifdef for PG 15"

This reverts commit c7b51025ab.

* Fixes tests for ALTER TRIGGER RENAME consistency for part. tables

Relevant PG commit:
80ba4bb383538a2ee846fece6a7b8da9518b6866

* Prevent creating child triggers on partitions when adding new node

Pre PG15, tgisinternal is true for a "child" trigger on a partition
cloned from the trigger on the parent.
In PG15, tgisinternal is false in that case. However, we don't want to
create this trigger on the partition since it will create a conflict
when we try to attach the partition to the parent table:
ERROR: trigger "..." for relation "{partition_name}" already exists

Relevant PG commit:
f4566345cf40b068368cb5617e61318da60676ec

* Fix tests for generated columns dependency changes

In PG15, For GENERATED columns, all dependencies of the generation
expression are recorded as NORMAL dependencies of the column itself.
This requires CASCADE to drop generated cols with the original col.
PRE PG15, dependencies were recorded as AUTO, with which
generated columns are silently dropped with the original column.

Relevant PG commit:
cb02fcb4c95bae08adaca1202c2081cfc81a28b5

* Explicitly cast catalog "char" column to text before concatenation

Relevant PG commit:
07eee5a0dc642d26f44d65c4e6263304208e8583

* Remove 'AS "?column?"' from test outputs

There were some instances in the following tst outputs
in planning debug outputs where AS "?column?" is added.
We add a normalization rule to remove it as it is not
important.

cte_inline.out
recursive_relation_planning_restriction_pushdown.out

Relevant PG commit:
c7461fc25558832dd347a9c8150b0f1ed85e36e8

* Use pg_backup_stop(PG15) instead of pg_stop_backup(PG<15)

Add an alternative test output because of the change in the
backup modes of Postgres. Specifically here, there is a renaming
issue: pg_stop_backup PRE PG15 vs pg_backup_stop PG15+
The alternative output can be deleted when we drop support for PG14

Relevant PG commit:
39969e2a1e4d7f5a37f3ef37d53bbfe171e7d77a

* Adds citus.mitmfifo GUC

Previously we setting this configuration parameter
in the fly for failure tests schedule.
However, PG15 doesn't allow that anymore: reserved prefixes
like "citus" cannot be used to set non-existing GUCs.

Relevant PG commit:
88103567cb8fa5be46dc9fac3e3b8774951a2be7

* Handles EXPLAIN output diffs in PG15 - Extra result lines

To handle extra "Result" lines in explain outputs, we add explain
method to multi_test_helpers.sql file
- plan_without_result_lines() is added for cases where we want the
whole explain output with only "Result" lines removed

* Handles EXPLAIN output diffs in PG15, Hash Agg/Join leverage

To handle differences in usage of GroupAggregate vs HashAggregate
or Merge Join vs Hash join in cases where this detail doesn't
seem to matter, we use coordinator_plan().
- coordinator_plan() is updated to remove "Result" lines

There are some cases where we have subplans so we add a new
function that prints all Task Count lines as well
- coordinator_plan_with_subplans()

Still not sure of the relevant PG commit
Could be db0d67db2401eb6238ccc04c6407a4fd4f985832
but disabling enable_group_by_reordering didn't help.

* Handles EXPLAIN output diffs in PG15: enable_group_by_reordering

Relevant PG commit
db0d67db2401eb6238ccc04c6407a4fd4f985832

* Normalizes Memory Usage, Buckets, Batches for PG15 explain diffs

We create a new function in multi_test_helpers, which is similar
to explain_merge function in PG15. This explain helper function
normalies Memory Usage, Buckets and Batches, and we use it in the
tests which give a different output for PG15.

* Bump test images to 15beta3 (#6172)

* Omit namespace in post-copy errmsg

Relevant PG commit:
069d33d0c5a021601245e44df77a0423ddd69359

* Handles EXPLAIN output diffs in PG15: extra arrows&result lines

To handle extra "->" arrows resulting from extra Result lines
in explain outputs, we add the following explain method to
multi_test_helpers.sql file

- plan_without_arrows() is added for cases where we want the
whole explain output without arrows and without Result lines

* Alters public schema's owner to pg_database_owner in PG15

In PG15, public schema is owned by pg_database_owner role.
In multi_extension, we drop and recreate the ppublic schema,
hence its owner become the default user in our tests, postgres.
Change that to pg_database_owner for PG15 consistency.

This results in alternative test output for public schema grants
in the following test:

grant_on_schema_propagation.sql

Relevant PG commit: b073c3ccd06e4cb845e121387a43faa8c68a7b62

* Add alternative test outputs for change in Insert Select display

citus_local_tables_queries.sql
coordinator_shouldhaveshards.sql
cte_inline.sql
insert_select_repartition.sql
intermediate_result_pruning.sql
local_shard_execution.sql
local_shard_execution_replicated.sql
multi_deparse_shard_query.sql
multi_insert_select.sql
multi_insert_select_conflict.sql
multi_mx_insert_select_repartition.sql
mx_coordinator_shouldhaveshards.sql
single_node.sql

Relevant PG commit:
a8d8445a7b2f80f6d0bfe97b19f90bd2cbef8759

* Fixes columnar tap tests for PG15

In PG15, Perl test modules have been moved to a new namespace.
Also, postgres node new() and get_new_node() methods have been
unified to one method: new()

We create separate tap tests for PG13/14 and PG15+
and update the Makefiles accordingly.

Relevant PG commits:
201a76183e2056c2217129e12d68c25ec9c559c8
b3b4d8e68ae83f432f43f035c7eb481ef93e1583

* Handles EXPLAIN output diffs in PG15: HashAgg Leverage,alt. output

Still not sure of the relevant PG commit
Could be db0d67db2401eb6238ccc04c6407a4fd4f985832
but disabling enable_group_by_reordering didn't help.
2022-08-24 17:59:17 +02:00
Onder Kalaci c7b51025ab Add missing ifdef for PG 15 2022-08-02 09:46:53 +02:00
Onur Tirtir 181111b84f Drop ruleutils copied for statistics 2022-01-20 17:28:19 +03:00
Onur Tirtir 7b59295af2 Drop ruleutils copied for triggers 2022-01-20 17:28:19 +03:00
Teja Mupparti a8348047c5
Pushdown procedures with OUT parameters (#5348) 2021-10-11 23:14:36 -07:00
Sait Talha Nisanci 0b67fcf81d Fix style 2021-09-03 16:09:59 +03:00
Halil Ozan Akgul 5930378f61 Renames shadowing ruleutils_14.c variables 2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 86d9260781 Uses lfirst_node in ruleutils_14.c
Relevant PG commit:
2b00db4fb0c7f02f000276bfadaab65a14059168
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 3b7bcf7555 Adds missing include_out_argument parameter to func_get_detail in ruleutils_14.c
Relevant PG commit:
e56bce5d43789cce95d099554ae9593ada92b3b7
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 2990cfb6c9 Adds SQL-standard function body support to ruleutils_14.c
Relevant PG commit:
e717a9a18b2e34c9c40e5259ad4d31cd7e420750
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 84f0be56c3 Adds EXTRACT cases to get_func_sql_syntax in ruleutils_14.c
Relevant PG commit:
a2da77cdb4661826482ebf2ddba1f953bc74afe4
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 131062d6b5 Removes ModifyTable check from set_deparse_plan in ruleutils_14.c
Relevant PG commit:
86dc90056dfdbd9d1b891718d2e5614e3e432f35
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul f557bae64c Adds JOIN ... USING alias to ruleutils_14.c
Relevant PG commit:
055fee7eb4dcc78e58672aef146334275e1cc40d
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul c3f0528607 Extends statistics on expressions in ruleutils_14.c
Relevant PG commit:
a4d75c86bf15220df22de0a92c819ecef9db3849
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul af2853d1de Adds GROUP BY DISTINCT to ruleutils_14.c
Relevant PG commit:
be45be9c33a85e72cdaeb9967e9f6d2d00199e09
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 5bb538543d Enhances cycle mark values at ruleutils_14.c
Relevant PG commit:
f4adc41c4f92cc91d507b19e397140c35bb9fd71
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 12b3c04fe3 Adds SEARCH and CYCLE clauses to ruleutils_14.c
Relevant PG commit:
3696a600e2292d43c00949ddf0352e4ebb487e5b
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 1174046a33 Adds bytea equivalents of ltrim() and rtrim() to ruleutils_14.c
Relevant PG commit:
a6cf3df4ebdcbc7857910a67f259705645383e9f
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 71691ecf06 Adds HASH_STRINGS flag to ruleutils_14.c
Relevant PG commit:
b3817f5f774663d55931dd4fab9c5a94a15ae7ab
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul e72bd0c1a1 Removes dependency.h from ruleutils_14.c
Relevant PG commit:
8b069ef5dca97cd737a5fd64c420df3cd61ec1c9
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul d4874f5ad2 Removes indexing.h header from ruleutils_14.c
Relevant PG commit:
bdc4edbea6fc847f806e1e7118d730e159512bfc
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 1cb865deb8 Adds SQL syntax function calls related changes to ruleutils_14.c
Relevant PG commit:
40c24bfef92530bd846e111c1742c2a54441c62c
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul b4f76303c6 Updates F_ARRAY_UNNEST to F_UNNEST_ANYARRAY in ruleutils_14.c
Relevant PG commit:
8e1f37c07aafd4bb7aa6e1e1982010af11f8b5c7
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 30f77b29a7 Fixes some appendStringInfos in ruleutils_14.c
Relevant PG commit:
110d81728a0a006abcf654543fc15346f8043dc0
2021-09-03 15:27:25 +03:00
Halil Ozan Akgul 69aa240b99 Adds for_each_from to ruleutils_14.c
Relevant PG commit:
56fe008996bc1a547ce60c8dddd2ca821cac163e
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul beb49f0d53 Updates AlternativeSubPlan comment in ruleutils_14.c
Relevant PG commit:
41efb8340877e8ffd0023bb6b2ef22ffd1ca014d
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul e642f6c97f Removes support for postfix operators from ruleutils_14.c
Relevant PG commit:
1ed6b895634ce0dc5fd4bd040e87252b32182cba
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul a710b3b949 Removes some comments with printf %.*s format from ruleutils_14.c
Relevant PG commit:

c410af098c46949e36607eb13689e697fa2def97
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul e38b75799d Fixes some indentation in ruleutils_14.c
Relevant PG commit:

fa27dd40d5c5f56a1ee837a75c97549e992e32a4
2021-09-03 15:27:24 +03:00
Halil Ozan Akgul 7a27d7cee3 Adds copy of ruleutils_13.c as ruleutils_14.c 2021-09-03 15:27:24 +03:00