Re: remaining sql/json patches

2024-04-01 Thread jian he
hi. +/* + * Recursively transform child JSON_TABLE plan. + * + * Default plan is transformed into a cross/union join of its nested columns. + * Simple and outer/inner plans are transformed into a JsonTablePlan by + * finding and transforming corresponding nested column. + * Sibling plans are recur

Re: remaining sql/json patches

2024-04-02 Thread jian he
On Fri, Mar 22, 2024 at 12:08 AM Amit Langote wrote: > > On Wed, Mar 20, 2024 at 9:53 PM Amit Langote wrote: > > I'll push 0001 tomorrow. > > Pushed that one. Here's the remaining JSON_TABLE() patch. > I know v45 is very different from v47. but v45 contains all the remaining features to be imple

Re: remaining sql/json patches

2024-04-02 Thread jian he
On Tue, Apr 2, 2024 at 9:57 PM Amit Langote wrote: > > Please let me know if you have further comments on 0001. I'd like to > get that in before spending more energy on 0002. > hi. some issues with the doc. i think, some of the "path expression" can be replaced by "path_expression". maybe not al

Re: remaining sql/json patches

2024-04-03 Thread jian he
On Wed, Apr 3, 2024 at 11:30 AM jian he wrote: > > On Tue, Apr 2, 2024 at 9:57 PM Amit Langote wrote: > > > > Please let me know if you have further comments on 0001. I'd like to > > get that in before spending more energy on 0002. > > -- a/src/backend/pars

Re: remaining sql/json patches

2024-04-03 Thread jian he
On Wed, Apr 3, 2024 at 3:15 PM jian he wrote: > > On Wed, Apr 3, 2024 at 11:30 AM jian he wrote: > > > > On Tue, Apr 2, 2024 at 9:57 PM Amit Langote wrote: > > > > > > Please let me know if you have further comments on 0001. I'd like to > > &g

Re: remaining sql/json patches

2024-04-03 Thread jian he
hi. + + json_table is an SQL/JSON function which + queries JSON data + and presents the results as a relational view, which can be accessed as a + regular SQL table. You can only use json_table inside the + FROM clause of a SELECT, + UPDATE, DELETE, or MERGE + statement. + the on

Re: remaining sql/json patches

2024-04-03 Thread jian he
On Wed, Apr 3, 2024 at 8:39 PM Amit Langote wrote: > > Attached updated patches. I have addressed your doc comments on 0001, > but not 0002 yet. > in v49, 0002. +\sv jsonb_table_view1 +CREATE OR REPLACE VIEW public.jsonb_table_view1 AS + SELECT id, +a1, +b1, +a11, +a21, +a22

Re: remaining sql/json patches

2024-04-04 Thread jian he
On Thu, Apr 4, 2024 at 2:41 PM jian he wrote: > > On Wed, Apr 3, 2024 at 8:39 PM Amit Langote wrote: > > > > Attached updated patches. I have addressed your doc comments on 0001, > > but not 0002 yet. > > > about v49, 0002. --tests setup. drop table if exists s

Re: remaining sql/json patches

2024-04-04 Thread jian he
On Thu, Apr 4, 2024 at 3:50 PM jian he wrote: > > On Thu, Apr 4, 2024 at 2:41 PM jian he wrote: > > > > On Wed, Apr 3, 2024 at 8:39 PM Amit Langote wrote: > > > > > > Attached updated patches. I have addressed your doc comments on 0001, > > > b

Re: add function argument names to regex* functions.

2024-04-04 Thread jian he
On Wed, Apr 3, 2024 at 4:45 AM Tom Lane wrote: > > jian he writes: > > On Thu, Jan 18, 2024 at 4:17 PM Peter Eisentraut > > wrote: > >> Reading back through the discussion, I wasn't quite able to interpret > >> the resolution regarding Oracle compatibi

Re: remaining sql/json patches

2024-04-05 Thread jian he
On Fri, Apr 5, 2024 at 8:35 PM Amit Langote wrote: > Here's one. Main changes: > > * Fixed a bug in get_table_json_columns() which caused nested columns > to be deparsed incorrectly, something Jian reported upthread. > * Simplified the algorithm in JsonTablePlanNextRow() > > I'll post another rev

Re: remaining sql/json patches

2024-04-05 Thread jian he
On Sat, Apr 6, 2024 at 2:03 PM Amit Langote wrote: > > > > > * problem with type "char". the view def output is not the same as > > the select * from v1. > > > > create or replace view v1 as > > SELECT col FROM s, > > JSON_TABLE(jsonb '{"d": ["hello", "hello1"]}', '$' as c1 > > COLUMNS(col "char"

Re: remaining sql/json patches

2024-04-06 Thread jian he
On Fri, Apr 5, 2024 at 8:35 PM Amit Langote wrote: > > On Thu, Apr 4, 2024 at 9:02 PM Amit Langote wrote: > > I'll post the rebased 0002 tomorrow after addressing your comments. > > Here's one. Main changes: > > * Fixed a bug in get_table_json_columns() which caused nested columns > to be depars

Re: remaining sql/json patches

2024-04-06 Thread jian he
hi. about v50. +/* + * JsonTableSiblingJoin - + * Plan to union-join rows of nested paths of the same level + */ +typedef struct JsonTableSiblingJoin +{ + JsonTablePlan plan; + + JsonTablePlan *lplan; + JsonTablePlan *rplan; +} JsonTableSiblingJoin; "Plan to union-join rows of nested paths of the

Re: remaining sql/json patches

2024-04-07 Thread jian he
On Sun, Apr 7, 2024 at 12:30 PM jian he wrote: > > other than that, it looks good to me. while looking at it again. + | NESTED path_opt Sconst + COLUMNS '(' json_table_column_definition_list ')' + { + JsonTableColumn *n = makeNode(JsonTableColumn); + + n->coltyp

Re: remaining sql/json patches

2024-04-07 Thread jian he
On Sun, Apr 7, 2024 at 9:36 PM Amit Langote wrote: > > > 0002 needs an expanded commit message but I've run out of energy today. > some cosmetic issues in v51, 0002. in struct JsonTablePathScan, /* ERROR/EMPTY ON ERROR behavior */ bool errorOnError; the comments seem not right. I think "errorOn

Re: remaining sql/json patches

2024-04-07 Thread jian he
On Mon, Apr 8, 2024 at 12:34 AM jian he wrote: > > On Sun, Apr 7, 2024 at 9:36 PM Amit Langote wrote: > > 0002 needs an expanded commit message but I've run out of energy today. > > > +/* + * Fetch next row from a JsonTablePlan's path evaluation result and f

Re: remaining sql/json patches

2024-04-07 Thread jian he
On Mon, Apr 8, 2024 at 11:21 AM jian he wrote: > > On Mon, Apr 8, 2024 at 12:34 AM jian he wrote: > > > > On Sun, Apr 7, 2024 at 9:36 PM Amit Langote wrote: > > > 0002 needs an expanded commit message but I've run out of energy today. > > > > >

sql/json remaining issue

2024-04-09 Thread jian he
hi. ` | NESTED [ PATH ] json_path_specification [ AS json_path_name ] COLUMNS ( json_table_column [, ...] ) NESTED [ PATH ] json_path_specification [ AS json_path_name ] COLUMNS ( json_table_column [, ...] ) ` "json_path_specification" should be "path_expression"?

Re: Can't find not null constraint, but \d+ shows that

2024-04-09 Thread jian he
On Wed, Apr 10, 2024 at 1:29 AM Alvaro Herrera wrote: > > On 2024-Mar-29, Tender Wang wrote: > > > I think aboved case can explain what's meaning about comments in > > dropconstraint_internal. > > But here, in RemoveConstraintById() , we only care about primary key case, > > so NOT NULL is better

Re: Can't find not null constraint, but \d+ shows that

2024-04-10 Thread jian he
another related bug, in master. drop table if exists notnull_tbl1; CREATE TABLE notnull_tbl1 (c0 int not null, c1 int); ALTER TABLE notnull_tbl1 ADD CONSTRAINT Q PRIMARY KEY(c0, c1); \d+ notnull_tbl1 ALTER TABLE notnull_tbl1 ALTER c0 DROP NOT NULL; ALTER TABLE notnull_tbl1 ALTER c1 DROP NOT NULL;

Re: Can't find not null constraint, but \d+ shows that

2024-04-10 Thread jian he
On Wed, Apr 10, 2024 at 7:01 PM Alvaro Herrera wrote: > > On 2024-Apr-10, jian he wrote: > > > another related bug, in master. > > > > drop table if exists notnull_tbl1; > > CREATE TABLE notnull_tbl1 (c0 int not null, c1 int); > > ALTER TABLE notnull_t

Re: POC, WIP: OR-clause support for indexes

2024-02-09 Thread jian he
On Thu, Feb 8, 2024 at 1:34 PM Andrei Lepikhov wrote: > > On 3/2/2024 02:06, Alena Rybakina wrote: > > On 01.02.2024 08:00, jian he wrote: > > I added your code to the patch. > Thanks Alena and Jian for the detailed scrutiny! > > A couple of questions: > 1. As I

Re: Patch: Add parse_type Function

2024-02-10 Thread jian he
+ /* + * Parse type-name argument to obtain type OID and encoded typmod. We don't + * need to check for parseTypeString failure, but just let the error be + * raised. The 0 arg works both as the `Node *escontext` arg in Postgres 16 + * and the `bool missing_ok` arg in 9.4-15. + */ + (void) parseTyp

Re: Change COPY ... ON_ERROR ignore to ON_ERROR ignore_row

2024-02-11 Thread jian he
c95bb7b7c072f510b9a60695714be21345f21591 Mon Sep 17 00:00:00 2001 From: jian he Date: Sat, 10 Feb 2024 15:08:41 +0800 Subject: [PATCH v2 1/1] on_error set_to_null any data type conversion errors while COPY FROM will set that column value to be NULL. discussion: https://www.postgresql.org/message-id/CAKFQuwawy1e6YR4S=j

Re: RFC: Logging plan of the running query

2024-02-11 Thread jian he
On Mon, Jan 29, 2024 at 9:02 PM torikoshia wrote: > > Hi, > > Updated the patch to fix typos and move > ProcessLogQueryPlanInterruptActive from errfinish() to AbortTransaction. > + + + + pg_log_query_plan + +pg_log_query_plan ( pid integer ) +b

Re: RFC: Logging plan of the running query

2024-02-11 Thread jian he
On Wed, Feb 7, 2024 at 12:58 PM Ashutosh Bapat wrote: > > > > > > */ > > > How bad this performance could be. Let's assume that a query is taking > > > time and pg_log_query_plan() is invoked to examine the plan of this > > > query. Is it possible that the looping over all the locks itself takes

Re: RFC: Logging plan of the running query

2024-02-11 Thread jian he
On Mon, Feb 12, 2024 at 12:42 PM Ashutosh Bapat wrote: > > On Mon, Feb 12, 2024 at 5:31 AM jian he wrote: > > > > On Wed, Feb 7, 2024 at 12:58 PM Ashutosh Bapat > > wrote: > > > > > > > > > > > > */ > > > > > How bad th

Re: [PATCH] Add sortsupport for range types and btree_gist

2024-02-12 Thread jian he
On Fri, Feb 9, 2024 at 2:14 AM Bernd Helmle wrote: > > Am Mittwoch, dem 10.01.2024 um 22:18 +0800 schrieb jian he: > > > > I split the original author's patch into 2. > > 1. Add GiST sortsupport function for all the btree-gist module data > > types except anyr

Re: POC, WIP: OR-clause support for indexes

2024-02-12 Thread jian he
On Thu, Feb 8, 2024 at 1:34 PM Andrei Lepikhov wrote: > A couple of questions: > 1. As I see, transformAExprIn uses the same logic as we invented but > allows composite and domain types. Could you add a comment explaining > why we forbid row types in general, in contrast to the transformAExprIn >

Re: SQL:2011 application time

2024-02-13 Thread jian he
Hi more minor issues. + FindFKComparisonOperators( + fkconstraint, tab, i, fkattnum, + &old_check_ok, &old_pfeqop_item, + pktypoid[i], fktypoid[i], opclasses[i], + is_temporal, false, + &pfeqoperators[i], &ppeqoperators[i], &ffeqoperators[i]); + } + if (is_temporal) { + pkattnum[numpks] = pkperiod

Re: Make COPY format extendable: Extract COPY TO format implementations

2024-02-15 Thread jian he
On Thu, Feb 15, 2024 at 2:34 PM Sutou Kouhei wrote: > > > Thanks for the info. Let's use InputFunctionCallSafeWithInfo(). > See that attached patch: > v2-0001-Reuse-fcinfo-used-in-COPY-FROM.patch > > I also attach a patch for COPY TO: > v1-0001-Reuse-fcinfo-used-in-COPY-TO.patch > > I measured the

Re: POC, WIP: OR-clause support for indexes

2024-02-15 Thread jian he
On Wed, Feb 14, 2024 at 11:21 AM Andrei Lepikhov wrote: > > So, this example is more about the subtle balance between > parallel/sequential execution, which can vary from one platform to another. > Hi, here I attached two files, expression_num_or_1_100.sql, expression_num_or_1_1.sql it has st

Re: POC, WIP: OR-clause support for indexes

2024-02-16 Thread jian he
On Fri, Feb 16, 2024 at 1:32 PM Andrei Lepikhov wrote: > > On 16/2/2024 07:00, jian he wrote: > > On Wed, Feb 14, 2024 at 11:21 AM Andrei Lepikhov > > wrote: > > My OS: Ubuntu 22.04.3 LTS > > I already set the max_parallel_workers_per_gather to 10. > > So for

Re: Add pg_basetype() function to obtain a DOMAIN base type

2024-02-16 Thread jian he
On Sat, Feb 17, 2024 at 2:16 AM Tomas Vondra wrote: > > Hi, > > On 1/2/24 01:00, jian he wrote: > > On Mon, Dec 4, 2023 at 5:11 PM John Naylor wrote: > >> > >> On Thu, Sep 28, 2023 at 12:22 AM Alexander Korotkov > >> wrote: > >>> The one

Re: Add pg_basetype() function to obtain a DOMAIN base type

2024-02-17 Thread jian he
On Sun, Feb 18, 2024 at 2:49 AM Tomas Vondra wrote: > > An alternative approach would be modifying pg_typeof() to optionally > determine the base type, depending on a new argument which would default > to "false" (i.e. the current behavior). > > So you'd do > > SELECT pg_typeof(x); > > or > >

Re: Emitting JSON to file using COPY TO

2024-02-18 Thread jian he
(Node *) > makeBoolean(true), @1); > + } > ; > > I believe we don't need to support new options in old-style syntax. > you are right about the force_array case. we don't need to add force_array related changes in gram.y. On Wed,

Re: Add pg_basetype() function to obtain a DOMAIN base type

2024-02-18 Thread jian he
#x27;s a chain of domain dependencies, it will recurse until finding the base type. + compared with pg_typeof's explanation, I feel like pg_basetype's explanation doesn't seem accurate. However, I don't know how to rephrase it. From a06f2de575da6e5fa45919c792f3dab2470f4927

Re: POC, WIP: OR-clause support for indexes

2024-02-19 Thread jian he
On Mon, Feb 19, 2024 at 4:35 PM Andrei Lepikhov wrote: > > In attachment - v17 for both patches. As I see it, the only general > explanation of the idea is not addressed. I'm not sure how deeply we > should explain it. > On Tue, Nov 28, 2023 at 5:04 AM Robert Haas wrote: > > On Mon, Nov 27, 202

Re: Patch: Add parse_type Function

2024-02-19 Thread jian he
On Tue, Feb 20, 2024 at 11:06 AM David E. Wheeler wrote: > > LOL, I missed that, just wrote it myself in the last hour. :-) v6 attached. > +SELECT to_regtypemod('interval nonesuch'); -- grammar error expected +ERROR: syntax error at or near "nonesuch" +LINE 1: SELECT to_regtypemod('interval none

Re: Catalog domain not-null constraints

2024-02-21 Thread jian he
wandering around the function AlterDomainNotNull, the following code can fix the previous undesired behavior. seems pretty simple, am I missing something? based on v3-0001-Add-tests-for-domain-related-information-schema-v.patch and v3-0002-Catalog-domain-not-null-constraints.patch diff --git a/src

Re: POC, WIP: OR-clause support for indexes

2024-02-24 Thread jian he
Hi. I wrote the first draft patch of the documentation. it's under the section: Planner Method Configuration (runtime-config-query.html) but this feature's main meat is in src/backend/parser/parse_expr.c so it may be slightly inconsistent, as mentioned by others. You can further furnish it. v1-0

Re: Improve readability by using designated initializers when possible

2024-02-26 Thread jian he
Hi. minor issues. @@ -2063,12 +2009,12 @@ find_expr_references_walker(Node *node, CoerceViaIO *iocoerce = (CoerceViaIO *) node; /* since there is no exposed function, need to depend on type */ - add_object_address(OCLASS_TYPE, iocoerce->resulttype, 0, + add_object_address(TypeRelationId iocoe

Re: clarify equalTupleDescs()

2024-02-27 Thread jian he
On Mon, Feb 12, 2024 at 7:47 PM Peter Eisentraut wrote: > > > In principle, hashRowType() could process all the fields that > equalRowTypes() does. But since it's only a hash function, it doesn't > have to be perfect. (This is also the case for the current > hashTupleDesc().) I'm not sure where

Re: bug report: some issues about pg_15_stable(8fa4a1ac61189efffb8b851ee77e1bc87360c445)

2024-02-28 Thread jian he
On Tue, Feb 27, 2024 at 8:53 PM Dean Rasheed wrote: > > Attached is a very rough patch. It seemed better to build the > projection in the executor rather than the planner, since then the > extra work can be avoided, if EPQ is not invoked. > > It seems to work (it passes the isolation tests, and I

Re: POC, WIP: OR-clause support for indexes

2024-02-28 Thread jian he
On Wed, Feb 28, 2024 at 12:19 PM Andrei Lepikhov wrote: > > On 26/2/2024 11:10, Alena Rybakina wrote: > > On 24.02.2024 14:28, jian he wrote: > >> Hi. > >> I wrote the first draft patch of the documentation. > >> it's under the section: Planner Method C

Re: bug report: some issues about pg_15_stable(8fa4a1ac61189efffb8b851ee77e1bc87360c445)

2024-02-28 Thread jian he
On Wed, Feb 28, 2024 at 8:11 PM Dean Rasheed wrote: > > On Wed, 28 Feb 2024 at 09:16, jian he wrote: > > > > + oldcontext = MemoryContextSwitchTo(estate->es_query_cxt); > > + > > + node->as_epq_tupdesc = lookup_rowtype_tupdesc_copy(tupType, tupTypmod); >

Re: Propagate sanity checks of ProcessUtility() to standard_ProcessUtility()?

2024-02-29 Thread jian he
On Thu, Feb 29, 2024 at 3:21 PM Michael Paquier wrote: > > Hi all, > > It's been brought to me that an extension may finish by breaking the > assumptions ProcessUtility() relies on when calling > standard_ProcessUtility(), causing breakages when passing down data to > cascading utility hooks. > >

Re: Improve readability by using designated initializers when possible

2024-02-29 Thread jian he
On Fri, Mar 1, 2024 at 12:08 PM Michael Paquier wrote: > > On Thu, Feb 29, 2024 at 12:41:38PM +0100, Peter Eisentraut wrote: > > On 27.02.24 08:57, Alvaro Herrera wrote: > >> On 2024-Feb-27, Michael Paquier wrote: > >>> These would cause compilation failures. Saying that, this is a very > >>> nic

src/include/miscadmin.h outdated comments

2024-03-01 Thread jian he
hi. /* * globals.h -- * */ The above comment src/include/miscadmin.h is not accurate? we don't have globals.h file?

Re: Improve readability by using designated initializers when possible

2024-03-03 Thread jian he
On Fri, Mar 1, 2024 at 5:26 PM Peter Eisentraut wrote: > > Oops, there was a second commit in my branch that I neglected to send > in. Here is my complete patch set. there is a `OCLASS` at the end of getObjectIdentityParts. there is a `ObjectClass` in typedefs.list

Re: POC, WIP: OR-clause support for indexes

2024-03-03 Thread jian he
On Thu, Feb 29, 2024 at 4:59 PM Andrei Lepikhov wrote: > > On 28/2/2024 17:27, Alena Rybakina wrote: > > Maybe like that: > > > > It also considers the way to generate a path using BitmapScan indexes, > > converting the transformed expression into expressions separated by "OR" > > operations, and

Re: Fix log_line_prefix to display the transaction id (%x) for statements not in a transaction block

2024-03-03 Thread jian he
On Mon, Mar 4, 2024 at 2:12 PM Andrey M. Borodin wrote: > > > On 12 Jan 2024, at 05:51, jian he wrote: > > > > another big difference compare to HEAD: > > Hi Jian, > > thanks for looking into this. Would you be willing to review the next version > of th

Re: remaining sql/json patches

2024-03-04 Thread jian he
On Tue, Mar 5, 2024 at 9:22 AM Amit Langote wrote: > > Thanks for the heads up. Attaching rebased patches. > Walking through the v41-0001-Add-SQL-JSON-query-functions.patch documentation. I found some minor cosmetic issues. + +select json_query(jsonb '{"a": "[1, 2]"}', 'lax $.a'

Re: remaining sql/json patches

2024-03-06 Thread jian he
On Wed, Mar 6, 2024 at 12:07 PM Amit Langote wrote: > > Hi Tomas, > > On Wed, Mar 6, 2024 at 6:30 AM Tomas Vondra > wrote: > > > > Hi, > > > > I know very little about sql/json and all the json internals, but I > > decided to do some black box testing. I built a large JSONB table > > (single colu

Re: remaining sql/json patches

2024-03-06 Thread jian he
On Wed, Mar 6, 2024 at 9:22 PM jian he wrote: > > Another case, I did test yet: more keys in a single json, but the > value is small. Another case attached. see the attached SQL file's comments. a single simple jsonb, with 33 keys, each key's value with fixed length: 25

Re: remaining sql/json patches

2024-03-06 Thread jian he
On Tue, Mar 5, 2024 at 12:38 PM Andy Fan wrote: > > > In the commit message of 0001, we have: > > """ > Both JSON_VALUE() and JSON_QUERY() functions have options for > handling EMPTY and ERROR conditions, which can be used to specify > the behavior when no values are matched and when an error occu

Re: remaining sql/json patches

2024-03-06 Thread jian he
two cosmetic minor issues. +/* + * JsonCoercion + * Information about coercing a SQL/JSON value to the specified + * type at runtime + * + * A node of this type is created if the parser cannot find a cast expression + * using coerce_type() or OMIT QUOTES is specified for JSON_QUERY. If the + * la

Re: remaining sql/json patches

2024-03-07 Thread jian he
On Thu, Mar 7, 2024 at 8:06 PM Amit Langote wrote: > > > Indeed. > > This boils down to the difference in the cast expression chosen to > convert the source value to int in the two cases. > > The case where the source value has no quotes, the chosen cast > expression is a FuncExpr for function num

Re: remaining sql/json patches

2024-03-07 Thread jian he
I looked at the documentation again. one more changes for JSON_QUERY: diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 3e58ebd2..0c49b321 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -18715,8 +18715,8 @@ ERROR: jsonpath array subscript is out of bounds

Re: POC, WIP: OR-clause support for indexes

2024-03-08 Thread jian he
+ if (!IsA(lfirst(lc), Invalid)) + { + or_list = lappend(or_list, lfirst(lc)); + continue; + } Currently `IsA(lfirst(lc)` works. but is this generally OK? I didn't find any other examples. do you need do cast, like `(Node *) lfirst(lc);` If I understand the logic correctly: In `foreach(lc, args)

Re: Emitting JSON to file using COPY TO

2024-03-08 Thread jian he
On Sat, Mar 9, 2024 at 2:03 AM Joe Conway wrote: > > On 3/8/24 12:28, Andrey M. Borodin wrote: > > Hello everyone! > > > > Thanks for working on this, really nice feature! > > > >> On 9 Jan 2024, at 01:40, Joe Conway wrote: > >> > >> Thanks -- will have a look > > > > Joe, recently folks proposed

Re: remaining sql/json patches

2024-03-10 Thread jian he
one more issue. + case JSON_VALUE_OP: + /* Always omit quotes from scalar strings. */ + jsexpr->omit_quotes = (func->quotes == JS_QUOTES_OMIT); + + /* JSON_VALUE returns text by default. */ + if (!OidIsValid(jsexpr->returning->typid)) + { + jsexpr->returning->typid = TEXTOID; + jsexpr->returning->t

Re: Adding OLD/NEW support to RETURNING

2024-03-10 Thread jian he
On Sat, Mar 9, 2024 at 3:53 AM Dean Rasheed wrote: > > > Attached is a new patch, now with docs (no other code changes). > Hi, some issues I found, while playing around with support-returning-old-new-v2.patch doc/src/sgml/ref/update.sgml: [ RETURNING [ WITH ( { OLD | NEW } AS output_alias [,

Re: Make COPY format extendable: Extract COPY TO format implementations

2024-03-10 Thread jian he
On Fri, Mar 8, 2024 at 8:23 AM Sutou Kouhei wrote: > > > This shows that the v17 approach doesn't affect the current > text/csv/binary implementations. (The v17 approach just adds > 2 new structs, Copy{From,To}Rountine, without changing the > current text/csv/binary implementations.) > > Can we pu

Re: remaining sql/json patches

2024-03-10 Thread jian he
On Sun, Mar 10, 2024 at 10:57 PM jian he wrote: > > one more issue. Hi one more documentation issue. after applied V42, 0001 to 0003, there are 11 appearance of `FORMAT JSON` in functions-json.html still not a single place explained what it is for. json_query ( context_item, path_expr

Re: remaining sql/json patches

2024-03-11 Thread jian he
one more issue. +-- Extension: non-constant JSON path +SELECT JSON_EXISTS(jsonb '{"a": 123}', '$' || '.' || 'a'); +SELECT JSON_VALUE(jsonb '{"a": 123}', '$' || '.' || 'a'); +SELECT JSON_VALUE(jsonb '{"a": 123}', '$' || '.' || 'b' DEFAULT 'foo' ON EMPTY); +SELECT JSON_QUERY(jsonb '{"a": 123}',

Re: remaining sql/json patches

2024-03-11 Thread jian he
Hi. more minor issues. by searching `elog(ERROR, "unrecognized node type: %d"` I found that generally enum is cast to int, before printing it out. I also found a related post at [1]. So I add the typecast to int, before printing it out. most of the refactored code is unlikely to be reachable, but

Re: SQL:2011 application time

2024-03-11 Thread jian he
+ + If the last column is marked with PERIOD, + it is treated in a special way. + While the non-PERIOD columns are treated normally + (and there must be at least one of them), + the PERIOD column is not compared for equality. + Instead the constraint is considered

Re: SQL:2011 application time

2024-03-11 Thread jian he
On Mon, Mar 11, 2024 at 3:46 PM Peter Eisentraut wrote: > > A few general comments on the tests: > > - In the INSERT commands, specify the column names explicitly. This > makes the tests easier to read (especially since the column order > between the PK and the FK table is sometimes different). >

Re: MERGE ... RETURNING

2024-03-12 Thread jian he
Hi, some minor issues: [ WITH with_query [, ...] ] MERGE INTO [ ONLY ] target_table_name [ * ] [ [ AS ] target_alias ] USING data_source ON join_condition when_clause [...] [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ] here the "WITH" part should have "[ RECURSIVE ]" like: [

Re: Make COPY format extendable: Extract COPY TO format implementations

2024-03-13 Thread jian he
On Mon, Mar 11, 2024 at 8:56 AM Sutou Kouhei wrote: > > Hi, > > In > "Re: Make COPY format extendable: Extract COPY TO format implementations" > on Mon, 11 Mar 2024 08:00:00 +0800, > jian he wrote: > > > Hi, here are my cents: > > Currently in

Re: SQL:2011 application time

2024-03-13 Thread jian he
in GetOperatorFromWellKnownStrategy: *strat = GistTranslateStratnum(opclass, instrat); if (*strat == InvalidStrategy) { HeapTuple tuple; tuple = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass)); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cache lookup failed for operator class %u", opclass); erepo

Re: RFC: Logging plan of the running query

2024-03-13 Thread jian he
On Wed, Mar 13, 2024 at 1:28 PM torikoshia wrote: > > On Fri, Feb 16, 2024 at 11:42 PM torikoshia > wrote: > > I'm not so sure about the implementation now, i.e. finding the next > > node > > to be executed from the planstate tree, but I'm going to try this > > approach. > > Attached a patch whic

Re: MERGE ... RETURNING

2024-03-13 Thread jian he
Hi mainly document issues. Other than that, it looks good! MERGE not supported in COPY MERGE not supported in WITH query These entries in src/backend/po.* need to be deleted if this patch is committed? -- RETURNING INSERT RETUR

Re: Infinite Interval

2022-12-30 Thread jian he
On Fri, Dec 30, 2022 at 10:47 PM Joseph Koshakow wrote: > I have another update, I cleaned up some of the error messages, fixed > the horology tests, and ran pgindent. > > - Joe > Hi, there. Since in float8 you can use '+inf', '+infinity', So should we also make interval '+infinity' valid? Also

128-bit integers can range only up to (2 ^ 63 -1)

2023-01-03 Thread jian he
include/pg_config.h 14: #define ALIGNOF_PG_INT128_TYPE 16 355: #define MAXIMUM_ALIGNOF 8 374: #define PG_INT128_TYPE __int128 /include/c.h 507: /* 508: * 128-bit signed and unsigned integers 509: * There currently is only limited support for such types. 510: * E.g. 128bit literals and snprintf

Re: 128-bit integers can range only up to (2 ^ 63 -1)

2023-01-03 Thread jian he
On Tue, Jan 3, 2023 at 8:50 PM Tom Lane wrote: > jian he writes: > > I am slightly confused by the int128 type. I thought the 128 bit integer > > means range type will be upto 2 ^ 127 - 1. > > Now just copy the above code and test the int128 range. > > int128 can only

Re: Infinite Interval

2023-01-04 Thread jian he
On Tue, Jan 3, 2023 at 6:14 AM Joseph Koshakow wrote: > I have another patch, this one adds validations to operations that > return intervals and updated error messages. I tried to give all of the > error messages meaningful text, but I'm starting to think that almost all > of them should just sa

Re: Infinite Interval

2023-01-05 Thread jian he
On Wed, Jan 4, 2023 at 10:13 PM jian he wrote: > > > On Tue, Jan 3, 2023 at 6:14 AM Joseph Koshakow wrote: > >> I have another patch, this one adds validations to operations that >> return intervals and updated error messages. I tried to give all of the >> error

How to generate the new expected out file.

2023-01-05 Thread jian he
Hi. I changed the src/test/regress/sql/interval.sql, How can I generate the new src/test/regress/expected/interval.out file.

Re: Infinite Interval

2023-01-05 Thread jian he
On Fri, Jan 6, 2023 at 6:54 AM Joseph Koshakow wrote: > Jian, > > I incorporated your changes and updated interval.out and ran > pgindent. Looks like some of the error messages have changed and we > have some issues with parsing "+infinity" after rebasing. > > - Joe > Looks like some of the erro

Re: Infinite Interval

2023-01-08 Thread jian he
On Sun, Jan 8, 2023 at 4:22 AM Joseph Koshakow wrote: > On Sat, Jan 7, 2023 at 3:05 PM Joseph Koshakow wrote: > > > > On Sat, Jan 7, 2023 at 3:04 PM Joseph Koshakow > wrote: > > > > > > I think this patch is just about ready for review, except for the > > > following two questions: > > > 1. S

multirange of arrays not working on postgresql 14

2022-04-22 Thread Jian He
select arraymultirange(arrayrange(array[1,2], array[2,1])); ERROR: 42883: function arrayrange(integer[], integer[]) does not exist > LINE 1: select arraymultirange(arrayrange(array[1,2], array[2,1])); >^ > HINT: No function matches the given name and argument type

Fwd: range of composite types!

2022-04-26 Thread Jian He
Hello. Just wondering if this is possible or not.. -- Forwarded message - From: Jian He Date: Tue, Apr 26, 2022 at 2:46 PM Subject: range of composite types! To: pgsql-general range of composite types. I found this would be a great idea!!! Question on stackoverflow <ht

interval_scale not work as expected?

2023-10-15 Thread jian he
Hi. ( SELECT interval(0) '1 day 01:23:45.6789' union all SELECT interval(1) '1 day 01:23:45.6789' union all SELECT interval(2) '1 day 01:23:45.6789' union all SELECT interval(3) '1 day 01:23:45.6789' union all SELECT inter

Re: SQL:2011 application time

2023-10-15 Thread jian he
On Tue, Sep 26, 2023 at 4:21 AM Paul Jungwirth wrote: > > On 9/24/23 21:52, jian he wrote: > > On Wed, Sep 20, 2023 at 10:50 AM Paul Jungwirth > > wrote: > >> > >> On 9/17/23 20:11, jian he wrote: > >>> small issues so far I found, v14. > >

Re: UniqueKey v2

2023-10-15 Thread jian he
hi. After `git am`, I still cannot build. ../../Desktop/pg_sources/main/postgres/src/backend/optimizer/path/uniquekey.c:125:45: error: variable ‘var’ set but not used [-Werror=unused-but-set-variable] 125 | Var*var; |

Re: remaining sql/json patches

2023-10-16 Thread jian he
On Mon, Oct 16, 2023 at 5:47 PM Amit Langote wrote: > > > We're currently looking into this case. > > Thanks for the report. I think I've figured out the problem -- > ExecEvalJsonExprCoercion() mishandles the EMPTY ARRAY ON EMPTY case. > > I'm reading the other 2 patches... > > -- > Thanks, Amit

Re: remaining sql/json patches

2023-10-17 Thread jian he
Hi. based on v22. I added some tests again json_value for the sake of coverager test. A previous email thread mentioned needing to check *empty in ExecEvalJsonExpr. since JSON_VALUE_OP, JSON_QUERY_OP, JSON_EXISTS_OP all need to have *empty cases, So I refactored a little bit. might be helpful. Ma

Re: More new SQL/JSON item methods

2023-10-18 Thread jian he
On Fri, Oct 6, 2023 at 7:47 PM Peter Eisentraut wrote: > > On 29.08.23 09:05, Jeevan Chalke wrote: > > v1-0001-Implement-jsonpath-.bigint-.integer-and-.number-m.patch > > > > This commit implements jsonpath .bigint(), .integer(), and .number() > > methods. The JSON string or a numeric value is co

Re: UniqueKey v2

2023-10-18 Thread jian he
On Tue, Oct 17, 2023 at 11:21 AM wrote: > > > thanks for the really good suggestion. Here is the newer version: > --- a/src/backend/optimizer/path/meson.build +++ b/src/backend/optimizer/path/meson.build @@ -10,4 +10,5 @@ backend_sources += files( 'joinrels.c', 'pathkeys.c', 'tidpath.c'

Re: Patch: Improve Boolean Predicate JSON Path Docs

2023-10-18 Thread jian he
On Tue, Oct 17, 2023 at 10:56 AM David E. Wheeler wrote: > > > Oh, I thought it would report issues from the files they were found in. > You’re right, I forgot a title. Fixed in v4. > > David > +Returns the result of a JSON path +predicate +check for the specified JSON va

Re: [PATCH] Add support function for containment operators

2023-10-20 Thread jian he
On Fri, Oct 20, 2023 at 12:01 AM Laurenz Albe wrote: > > On Fri, 2023-10-13 at 14:26 +0800, jian he wrote: > > Collation problem seems solved. > > I didn't review your patch in detail, there is still a problem > with my example: > > CREATE TYPE textrange

Re: SQL:2011 application time

2023-10-20 Thread jian he
Hi. based on v16. /* Look up the FOR PORTION OF name requested. */ range_attno = attnameAttNum(targetrel, range_name, false); if (range_attno == InvalidAttrNumber) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column or period \"%s\" of relation \"%s\" does not exist", range_name, Rel

Re: UniqueKey v2

2023-10-22 Thread jian he
On Fri, Oct 20, 2023 at 4:33 PM wrote: > > > > i did some simple tests using text data type. > > > > it works with the primary key, not with unique indexes. > > it does not work when the column is unique, not null. > > > > The following is my test. > > Can you simplify your test case please? I can

Re: SQL:2011 application time

2023-10-22 Thread jian he
hi. also based on v16. -tests. drop table if exists for_portion_of_test1; CREATE unlogged TABLE for_portion_of_test1 (id int4range, valid_at tsrange,name text ); INSERT INTO for_portion_of_test1 VALUES ('[1,1]', NULL, '[1,1]_NULL'),('[1,1]', '(,)', '()_[1,]') ,('[1,1]', 'empty', '[

Re: More new SQL/JSON item methods

2023-10-23 Thread jian he
On Mon, Oct 23, 2023 at 3:29 PM Jeevan Chalke wrote: > > Attached are all three patches fixing the above comments. > minor issue: /src/backend/utils/adt/jsonpath_exec.c 2531: Timestamp result; 2532: ErrorSaveContext escontext = {T_ErrorSaveContext}; 2533: 2534: /* Get a warning when precision is

Re: SQL:2011 application time

2023-10-24 Thread jian he
On Wed, Oct 11, 2023 at 12:47 PM Paul Jungwirth wrote: > > On 9/25/23 14:00, Peter Eisentraut wrote: > > Looking through the tests in v16-0001: > > > > +-- PK with no columns just WITHOUT OVERLAPS: > > +CREATE TABLE temporal_rng ( > > + valid_at tsrange, > > + CONSTRAINT temporal_rng_p

maybe a type_sanity. sql bug

2023-10-26 Thread jian he
hi. The test seems to assume the following sql query should return zero row. but it does not. I don't know much about the "relreplident" column. https://git.postgresql.org/cgit/postgresql.git/tree/src/test/regress/expected/type_sanity.out#n499 demo: https://dbfiddle.uk/QFM88S2e test1=# \dt Did no

<    1   2   3   4   5   6   7   8   9   10   >