Skip to content

Commit 281231c

Browse files
Revert deparse.c duckdb_quote_identifier changes
deparse.c output is only used as an intermediate SQL string passed to ParseQuery() to reconstruct a Query AST; it is never sent to DuckDB directly. The AST is then re-deparsed by PreparePGDuckSQLTemplate / pg_get_querydef, whose output is post-processed by RequoteDuckDBReservedInSQL. The duckdb_quote_identifier calls in deparse.c are therefore dead code for DuckDB quoting purposes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: David Christensen <david.christensen@snowflake.com>
1 parent 2c882d9 commit 281231c

1 file changed

Lines changed: 7 additions & 18 deletions

File tree

pg_lake_table/src/fdw/deparse.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@
4141
* with collations that match the remote table's columns, which we can
4242
* consider to be user error.
4343
*
44-
* Identifier quoting in this file uses duckdb_quote_identifier() rather than
45-
* quote_identifier() because all SQL generated here is sent to pgduck_server
46-
* (DuckDB), not PostgreSQL. DuckDB reserves additional keywords (LAMBDA,
47-
* PIVOT, QUALIFY, etc.) that PostgreSQL does not; duckdb_quote_identifier()
48-
* handles those.
49-
*
50-
* TODO: this file was ported from postgres_fdw and has not been fully audited
51-
* for other DuckDB SQL compatibility issues (e.g. operator syntax, type casts).
52-
* See https://github.com/Snowflake-Labs/pg_lake/issues/277.
53-
*
5444
* Portions Copyright (c) 2012-2023, PostgreSQL Global Development Group
5545
*
5646
*-------------------------------------------------------------------------
@@ -91,7 +81,6 @@
9181
#include "pg_lake/extensions/postgis.h"
9282
#include "pg_lake/fdw/pg_lake_table.h"
9383
#include "pg_lake/fdw/shippable.h"
94-
#include "pg_lake/pgduck/keywords.h"
9584
#include "pg_lake/pgduck/type.h"
9685
#include "pg_lake/pgduck/rewrite_query.h"
9786
#include "pg_lake/planner/restriction_collector.h"
@@ -2231,7 +2220,7 @@ deparseAnalyzeSql(StringInfo buf, Relation rel,
22312220
}
22322221
}
22332222

2234-
appendStringInfoString(buf, duckdb_quote_identifier(colname));
2223+
appendStringInfoString(buf, quote_identifier(colname));
22352224

22362225
*retrieved_attrs = lappend_int(*retrieved_attrs, i + 1);
22372226
}
@@ -2469,7 +2458,7 @@ deparseColumnRef(StringInfo buf, int varno, int varattno, RangeTblEntry *rte,
24692458
if (qualify_col)
24702459
ADD_REL_QUALIFIER(buf, GetUniqueRelationIdentifier(rte));
24712460

2472-
appendStringInfoString(buf, duckdb_quote_identifier(colname));
2461+
appendStringInfoString(buf, quote_identifier(colname));
24732462
}
24742463
}
24752464

@@ -2512,7 +2501,7 @@ deparseRelation(StringInfo buf, Relation rel)
25122501
relname = RelationGetRelationName(rel);
25132502

25142503
appendStringInfo(buf, "%s.%s",
2515-
duckdb_quote_identifier(nspname), duckdb_quote_identifier(relname));
2504+
quote_identifier(nspname), quote_identifier(relname));
25162505
}
25172506

25182507
/*
@@ -3106,7 +3095,7 @@ deparseOperatorName(StringInfo buf, Form_pg_operator opform)
31063095
opnspname = get_namespace_name(opform->oprnamespace);
31073096
/* Print fully qualified operator name. */
31083097
appendStringInfo(buf, "OPERATOR(%s.%s)",
3109-
duckdb_quote_identifier(opnspname), opname);
3098+
quote_identifier(opnspname), opname);
31103099
}
31113100
else
31123101
{
@@ -3532,7 +3521,7 @@ deparseFieldSelect(FieldSelect *fieldSelect, deparse_expr_cxt *context)
35323521
attr_index,
35333522
false);
35343523

3535-
appendStringInfoString(context->buf, duckdb_quote_identifier(field_name));
3524+
appendStringInfoString(context->buf, quote_identifier(field_name));
35363525
}
35373526

35383527
/*
@@ -3767,12 +3756,12 @@ appendFunctionName(Oid funcid, deparse_expr_cxt *context)
37673756
const char *schemaname;
37683757

37693758
schemaname = get_namespace_name(procform->pronamespace);
3770-
appendStringInfo(buf, "%s.", duckdb_quote_identifier(schemaname));
3759+
appendStringInfo(buf, "%s.", quote_identifier(schemaname));
37713760
}
37723761

37733762
/* Always print the function name */
37743763
proname = NameStr(procform->proname);
3775-
appendStringInfoString(buf, duckdb_quote_identifier(proname));
3764+
appendStringInfoString(buf, quote_identifier(proname));
37763765

37773766
ReleaseSysCache(proctup);
37783767
}

0 commit comments

Comments
 (0)