Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: support pg_get_indexdef with 3 arguments #26629

Closed
knz opened this issue Jun 12, 2018 · 1 comment
Closed

sql: support pg_get_indexdef with 3 arguments #26629

knz opened this issue Jun 12, 2018 · 1 comment
Assignees
Labels
A-sql-builtins SQL built-in functions and semantics thereof. A-sql-pgcompat Semantic compatibility with PostgreSQL C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Milestone

Comments

@knz
Copy link
Contributor

knz commented Jun 12, 2018

Needed for #16971.

Used in this query, already listed in the srfs logic test file.

SELECT NULL AS table_cat,
       n.nspname AS table_schem,
       ct.relname AS TABLE_NAME,
       NOT i.indisunique AS non_unique,
       NULL AS index_qualifier,
       ci.relname AS index_name,
       CASE i.indisclustered
         WHEN TRUE THEN 1
         ELSE CASE am.amname
           WHEN 'hash' THEN 2
           ELSE 3
         END
       END AS TYPE,
       (i.KEYS).n AS ordinal_position,
       trim(BOTH '"' FROM pg_catalog.pg_get_indexdef(ci.oid, (i.KEYS).n, FALSE)) AS COLUMN_NAME,
       CASE am.amcanorder
         WHEN TRUE THEN CASE i.indoption[(i.keys).n - 1] & 1
           WHEN 1 THEN 'D'
           ELSE 'A'
         END
         ELSE NULL
       END AS asc_or_desc,
       ci.reltuples AS CARDINALITY,
       ci.relpages AS pages,
       pg_catalog.pg_get_expr(i.indpred, i.indrelid) AS filter_condition
FROM pg_catalog.pg_class ct
JOIN pg_catalog.pg_namespace n ON (ct.relnamespace = n.oid)
JOIN (
  SELECT i.indexrelid,
         i.indrelid,
         i.indoption,
         i.indisunique,
         i.indisclustered,
         i.indpred,
         i.indexprs,
         information_schema._pg_expandarray(i.indkey) AS KEYS
  FROM pg_catalog.pg_index i
) i
  ON (ct.oid = i.indrelid)
JOIN pg_catalog.pg_class ci ON (ci.oid = i.indexrelid)
JOIN pg_catalog.pg_am am ON (ci.relam = am.oid)
WHERE TRUE
  AND n.nspname = 'public'
  AND ct.relname = 'j'
ORDER BY non_unique,
         TYPE,
         index_name,
         ordinal_position
@knz knz added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-builtins SQL built-in functions and semantics thereof. labels Jun 12, 2018
craig bot pushed a commit that referenced this issue Jun 14, 2018
26628: sql: Support tuple column access and tuple stars r=knz a=knz

First commits from #26621.
Completes the fix to #24866 by re-activating disabled tests.
This work is yet another step towards #16971. It would actually fix #16971 if it were not for #26627, #26624 and #26629.

This work is yet another step towards #16971.

The labeled tuples introduced in #25283 can now be accessed using
their labels or using a star, e.g. `(E).*`.

Release note (sql change): Labeled tuples can now be accessed using
their labels (e.g. `SELECT (x).word FROM (SELECT pg_expand_keywords()
AS x)` or a star (e.g. `SELECT (x).* FROM (SELECT pg_expand_keywords()
AS x)`).

Fixes #26720.

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
Co-authored-by: Bram Gruneir <bram@cockroachlabs.com>
@bsnyder788
Copy link
Contributor

I opened #27161 to add support for pg_get_indexdef with 3 arguments. The test above still can't be uncommented as is though because it complains about pg_am.amcanorder still not existing.

craig bot pushed a commit that referenced this issue Jul 7, 2018
27161: sql: support pg_get_indexdef with 3 arguments r=knz a=bsnyder788

Fixes #26629 

Co-authored-by: Brett Snyder <bsnyder788@gmail.com>
@craig craig bot closed this as completed in #27161 Jul 7, 2018
@knz knz added this to the 2.1 milestone Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-builtins SQL built-in functions and semantics thereof. A-sql-pgcompat Semantic compatibility with PostgreSQL C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Projects
None yet
Development

No branches or pull requests

3 participants