pgsql: worker_spi: Switch to TAP tests

2023-07-26 Thread Michael Paquier
worker_spi: Switch to TAP tests This commit moves worker_spi to use TAP tests. sql/worker_spi.sql is gone, replaced by an equivalent set of queries in a TAP script, without worker_spi loaded in shared_preload_libraries: - One query to launch a worker dynamically, relying now on "postgres" as the

pgsql: Fix performance problem with new COPY DEFAULT code

2023-07-26 Thread David Rowley
Fix performance problem with new COPY DEFAULT code 9f8377f7a added code to allow COPY FROM insert a column's default value when the input matches the DEFAULT string specified in the COPY command. Here we fix some inefficient code which needlessly palloc0'd an array to store if we should use the d

pgsql: Fix performance problem with new COPY DEFAULT code

2023-07-26 Thread David Rowley
Fix performance problem with new COPY DEFAULT code 9f8377f7a added code to allow COPY FROM insert a column's default value when the input matches the DEFAULT string specified in the COPY command. Here we fix some inefficient code which needlessly palloc0'd an array to store if we should use the d

pgsql: Add sanity asserts for index OID and attnums during cache init

2023-07-26 Thread Michael Paquier
Add sanity asserts for index OID and attnums during cache init There was already a check on the relation OID, but not its index OID and the attributes that can be used during the syscache lookups. The two assertions added by this commit are cheap, and actually useful for developers to fasten the

pgsql: Show savepoint names as constants in pg_stat_statements

2023-07-26 Thread Michael Paquier
Show savepoint names as constants in pg_stat_statements In pg_stat_statements, savepoint names now show up as constants with a parameter symbol, using as base query string the one added as a new entry to the PGSS hash table, leading to: RELEASE $1 ROLLBACK TO $1 SAVEPOINT $1 Applying constants to

pgsql: Adjust extra lines generated by psql to be valid SQL comments.

2023-07-26 Thread Nathan Bossart
Adjust extra lines generated by psql to be valid SQL comments. psql's --echo-hidden, --log-file, and --single-step options generate extra lines to clearly separate queries from other output. Presently, these extra lines are not valid SQL comments, which makes them a hazard for anyone trying to cop

pgsql: Add more SQL/JSON constructor functions

2023-07-26 Thread Amit Langote
Add more SQL/JSON constructor functions This Patch introduces three SQL standard JSON functions: JSON() JSON_SCALAR() JSON_SERIALIZE() JSON() produces json values from text, bytea, json or jsonb values, and has facilitites for handling duplicate keys. JSON_SCALAR() produces a json value from an

pgsql: Rename a nonterminal used in SQL/JSON grammar

2023-07-26 Thread Amit Langote
Rename a nonterminal used in SQL/JSON grammar This renames json_output_clause_opt to json_returning_clause_opt, because the new name makes more sense given that the governing keyword is RETURNING. Per suggestion from Álvaro Herrera. Discussion: https://postgr.es/m/20230707122820.wy5zlmhn4tdzbojl

pgsql: Some refactoring to export json(b) conversion functions

2023-07-26 Thread Amit Langote
Some refactoring to export json(b) conversion functions This is to export datum_to_json(), datum_to_jsonb(), and jsonb_from_cstring(), though the last one is exported as jsonb_from_text(). A subsequent commit to add new SQL/JSON constructor functions will need them for calling from the executor.