Immediately after switching the page, it will work with CSR.
Please reload your browser to see how it works.

Source:https://github.com/SoraKumo001/next-streaming

⬅️ Bringing psql’s \d to your web browser
arp242 11 daysReload
I always thought that most \-commands in psql were just frontends for queries? For example:

  % psql db_name
  
  (1)=# \set ECHO_HIDDEN
  
  (1)=# \d
  ********* QUERY **********
  SELECT n.nspname as "Schema",
    c.relname as "Name",
    CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'm' THEN 'materialized view' WHEN 'i' THEN 'index' WHEN 'S' TH
  EN 'sequence' WHEN 't' THEN 'TOAST table' WHEN 'f' THEN 'foreign table' WHEN 'p' THEN 'partitioned table' WHEN 'I' THEN 'partit
  ioned index' END as "Type",
    pg_catalog.pg_get_userbyid(c.relowner) as "Owner"
  FROM pg_catalog.pg_class c
       LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
       LEFT JOIN pg_catalog.pg_am am ON am.oid = c.relam
  WHERE c.relkind IN ('r','p','v','m','S','f','')
        AND n.nspname <> 'pg_catalog'
        AND n.nspname !~ '^pg_toast'
        AND n.nspname <> 'information_schema'
    AND pg_catalog.pg_table_is_visible(c.oid)
  ORDER BY 1,2;
  **************************
  
                            List of relations
   Schema │                  Name                  │   Type   │ Owner
  ────────┼────────────────────────────────────────┼──────────┼────────
  ...
I re-implemented quite a bit of that in a PostgreSQL management tool I built, based just on the ECHO_HIDDEN queries. Never even had to look at any C code.

I'm not sure if I entirely follow what translating C to JS gives you, other than a bit of (fairly simple) parsing of \cmd and flags? I didn't look too carefully at the code, so maybe I'm missing something.


williamjackson 11 daysReload
The fact that this is not a manual reimplementation, but a "transpilation" of the psql source from C to JavaScript, makes this super interesting to me.

    From the Postgres master branch (17devel), we take exec_command_d, exec_command_list and exec_command_sf_sv from command.c, and all of describe.c and sql_help.c, from src/bin/psql.
    We use plenty of RegExp search-and-replace to turn this C code into valid JS syntax.
    We implement some C library functions, such as strlen and strchr, and some Postgres support functions, such as printTable and printQuery, in JavaScript.
Read more here: https://neon.tech/blog/bringing-psqls-d-to-your-web-browser

gmac 11 daysReload
OP and library author here. You’ll find the background to this in this blog post: https://neon.tech/blog/bringing-psqls-d-to-your-web-browser

darby_eight 11 daysReload
This seems really cool, but also a nightmare to maintain. What are the plans for keeping this in sync with the upstream codebase?

stuaxo 11 daysReload
Thw convertet is nice, I could imagine it being it's own library, with the generator, and a release including the generated code every postures release.