Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/endtoend/testdata/ddl_create_func_exists/query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CREATE FUNCTION f(x TIMESTAMPTZ) RETURNS void AS '' LANGUAGE sql;
CREATE FUNCTION f(x timestamp with time zone) RETURNS void AS '' LANGUAGE sql;

-- name: F :one
SELECT f(1);
11 changes: 11 additions & 0 deletions internal/endtoend/testdata/ddl_create_func_exists/sqlc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "1",
"packages": [
{
"path": "go",
"name": "querytest",
"schema": "query.sql",
"queries": "query.sql"
}
]
}
2 changes: 2 additions & 0 deletions internal/endtoend/testdata/ddl_create_func_exists/stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# package querytest
query.sql:1:1: relation "f" already exists
12 changes: 11 additions & 1 deletion internal/sql/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,17 @@ func sameType(a, b *ast.TypeName) bool {
if a.Catalog != b.Catalog {
return false
}
if a.Schema != b.Schema {
// The pg_catalog schema is searched by default, so take that into
// account when comparing schemas
aSchema := a.Schema
bSchema := b.Schema
if aSchema == "pg_catalog" {
aSchema = ""
}
if bSchema == "pg_catalog" {
bSchema = ""
}
if aSchema != bSchema {
return false
}
if a.Name != b.Name {
Expand Down