diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2022-01-14 10:46:49 +0100 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2022-01-17 10:38:23 +0100 |
commit | 941460fcf731a32e6a90691508d5cfa3d1f8eeaf (patch) | |
tree | 2de0be4abcf7db131607ce9ba590a8040c16d6e3 /contrib/postgres_fdw/postgres_fdw.c | |
parent | ca86a63d207aca1f52ff13a1ce13854681d1bbf9 (diff) | |
download | postgresql-941460fcf731a32e6a90691508d5cfa3d1f8eeaf.tar.gz postgresql-941460fcf731a32e6a90691508d5cfa3d1f8eeaf.zip |
Add Boolean node
Before, SQL-level boolean constants were represented by a string with
a cast, and internal Boolean values in DDL commands were usually
represented by Integer nodes. This takes the place of both of these
uses, making the intent clearer and having some amount of type safety.
Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/8c1a2e37-c68d-703c-5a83-7a6077f4f997@enterprisedb.com
Diffstat (limited to 'contrib/postgres_fdw/postgres_fdw.c')
-rw-r--r-- | contrib/postgres_fdw/postgres_fdw.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/contrib/postgres_fdw/postgres_fdw.c b/contrib/postgres_fdw/postgres_fdw.c index 09a3f5e23cb..bf3f3d9e26e 100644 --- a/contrib/postgres_fdw/postgres_fdw.c +++ b/contrib/postgres_fdw/postgres_fdw.c @@ -103,7 +103,7 @@ enum FdwModifyPrivateIndex FdwModifyPrivateTargetAttnums, /* Length till the end of VALUES clause (as an Integer node) */ FdwModifyPrivateLen, - /* has-returning flag (as an Integer node) */ + /* has-returning flag (as a Boolean node) */ FdwModifyPrivateHasReturning, /* Integer list of attribute numbers retrieved by RETURNING */ FdwModifyPrivateRetrievedAttrs @@ -122,11 +122,11 @@ enum FdwDirectModifyPrivateIndex { /* SQL statement to execute remotely (as a String node) */ FdwDirectModifyPrivateUpdateSql, - /* has-returning flag (as an Integer node) */ + /* has-returning flag (as a Boolean node) */ FdwDirectModifyPrivateHasReturning, /* Integer list of attribute numbers retrieved by RETURNING */ FdwDirectModifyPrivateRetrievedAttrs, - /* set-processed flag (as an Integer node) */ + /* set-processed flag (as a Boolean node) */ FdwDirectModifyPrivateSetProcessed }; @@ -280,9 +280,9 @@ typedef struct PgFdwAnalyzeState */ enum FdwPathPrivateIndex { - /* has-final-sort flag (as an Integer node) */ + /* has-final-sort flag (as a Boolean node) */ FdwPathPrivateHasFinalSort, - /* has-limit flag (as an Integer node) */ + /* has-limit flag (as a Boolean node) */ FdwPathPrivateHasLimit }; @@ -1245,9 +1245,9 @@ postgresGetForeignPlan(PlannerInfo *root, */ if (best_path->fdw_private) { - has_final_sort = intVal(list_nth(best_path->fdw_private, + has_final_sort = boolVal(list_nth(best_path->fdw_private, FdwPathPrivateHasFinalSort)); - has_limit = intVal(list_nth(best_path->fdw_private, + has_limit = boolVal(list_nth(best_path->fdw_private, FdwPathPrivateHasLimit)); } @@ -1879,7 +1879,7 @@ postgresPlanForeignModify(PlannerInfo *root, return list_make5(makeString(sql.data), targetAttrs, makeInteger(values_end_len), - makeInteger((retrieved_attrs != NIL)), + makeBoolean((retrieved_attrs != NIL)), retrieved_attrs); } @@ -1916,7 +1916,7 @@ postgresBeginForeignModify(ModifyTableState *mtstate, FdwModifyPrivateTargetAttnums); values_end_len = intVal(list_nth(fdw_private, FdwModifyPrivateLen)); - has_returning = intVal(list_nth(fdw_private, + has_returning = boolVal(list_nth(fdw_private, FdwModifyPrivateHasReturning)); retrieved_attrs = (List *) list_nth(fdw_private, FdwModifyPrivateRetrievedAttrs); @@ -2567,9 +2567,9 @@ postgresPlanDirectModify(PlannerInfo *root, * Items in the list must match enum FdwDirectModifyPrivateIndex, above. */ fscan->fdw_private = list_make4(makeString(sql.data), - makeInteger((retrieved_attrs != NIL)), + makeBoolean((retrieved_attrs != NIL)), retrieved_attrs, - makeInteger(plan->canSetTag)); + makeBoolean(plan->canSetTag)); /* * Update the foreign-join-related fields. @@ -2667,11 +2667,11 @@ postgresBeginDirectModify(ForeignScanState *node, int eflags) /* Get private info created by planner functions. */ dmstate->query = strVal(list_nth(fsplan->fdw_private, FdwDirectModifyPrivateUpdateSql)); - dmstate->has_returning = intVal(list_nth(fsplan->fdw_private, + dmstate->has_returning = boolVal(list_nth(fsplan->fdw_private, FdwDirectModifyPrivateHasReturning)); dmstate->retrieved_attrs = (List *) list_nth(fsplan->fdw_private, FdwDirectModifyPrivateRetrievedAttrs); - dmstate->set_processed = intVal(list_nth(fsplan->fdw_private, + dmstate->set_processed = boolVal(list_nth(fsplan->fdw_private, FdwDirectModifyPrivateSetProcessed)); /* Create context for per-tuple temp workspace. */ @@ -6566,7 +6566,7 @@ add_foreign_ordered_paths(PlannerInfo *root, RelOptInfo *input_rel, * Build the fdw_private list that will be used by postgresGetForeignPlan. * Items in the list must match order in enum FdwPathPrivateIndex. */ - fdw_private = list_make2(makeInteger(true), makeInteger(false)); + fdw_private = list_make2(makeBoolean(true), makeBoolean(false)); /* Create foreign ordering path */ ordered_path = create_foreign_upper_path(root, @@ -6797,8 +6797,8 @@ add_foreign_final_paths(PlannerInfo *root, RelOptInfo *input_rel, * Build the fdw_private list that will be used by postgresGetForeignPlan. * Items in the list must match order in enum FdwPathPrivateIndex. */ - fdw_private = list_make2(makeInteger(has_final_sort), - makeInteger(extra->limit_needed)); + fdw_private = list_make2(makeBoolean(has_final_sort), + makeBoolean(extra->limit_needed)); /* * Create foreign final path; this gets rid of a no-longer-needed outer |