Skip to content

Commit

Permalink
Add unmodified ruleutils source files from PG16 and PG17 (#140)
Browse files Browse the repository at this point in the history
Postgres contains code in the `src/backend/utils/adt/ruleutils.c` file
to build a query string from a `Query *`. We also need to do this to be
able to send a query string to DuckDB, and we started using this
functionality in #130. Sadly this part of the Postgres code is not
extendable at all, and we do need to make some small changes.

So this vendors in the files, one for each supported postgres version.
This commit does not make any changes yet.
  • Loading branch information
JelteF committed Sep 11, 2024
1 parent 6cd9d91 commit e963297
Show file tree
Hide file tree
Showing 3 changed files with 26,010 additions and 0 deletions.
54 changes: 54 additions & 0 deletions include/pgduckdb/vendor/pg_ruleutils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*-------------------------------------------------------------------------
*
* ruleutils.h
* Declarations for ruleutils.c
*
* Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/utils/ruleutils.h
*
*-------------------------------------------------------------------------
*/
#ifndef RULEUTILS_H
#define RULEUTILS_H

#include "nodes/nodes.h"
#include "nodes/parsenodes.h"
#include "nodes/pg_list.h"

struct Plan; /* avoid including plannodes.h here */
struct PlannedStmt;

/* Flags for pg_get_indexdef_columns_extended() */
#define RULE_INDEXDEF_PRETTY 0x01
#define RULE_INDEXDEF_KEYS_ONLY 0x02 /* ignore included attributes */

extern char *pg_get_indexdef_string(Oid indexrelid);
extern char *pg_get_indexdef_columns(Oid indexrelid, bool pretty);
extern char *pg_get_indexdef_columns_extended(Oid indexrelid,
bits16 flags);
extern char *pg_get_querydef(Query *query, bool pretty);

extern char *pg_get_partkeydef_columns(Oid relid, bool pretty);
extern char *pg_get_partconstrdef_string(Oid partitionId, char *aliasname);

extern char *pg_get_constraintdef_command(Oid constraintId);
extern char *deparse_expression(Node *expr, List *dpcontext,
bool forceprefix, bool showimplicit);
extern List *deparse_context_for(const char *aliasname, Oid relid);
extern List *deparse_context_for_plan_tree(struct PlannedStmt *pstmt,
List *rtable_names);
extern List *set_deparse_context_plan(List *dpcontext,
struct Plan *plan, List *ancestors);
extern List *select_rtable_names_for_explain(List *rtable,
Bitmapset *rels_used);
extern char *generate_collation_name(Oid collid);
extern char *generate_opclass_name(Oid opclass);
extern char *get_range_partbound_string(List *bound_datums);

extern char *pg_get_statisticsobjdef_string(Oid statextid);

extern char *get_list_partvalue_string(Const *val);

#endif /* RULEUTILS_H */
Loading

0 comments on commit e963297

Please sign in to comment.