GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Don't load enum definitions on old PG · roji/Npgsql@da2614a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/Npgsql
    • NpgsqlDatabaseInfo.cs
    • PostgresDatabaseInfo.cs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/Npgsql/NpgsqlDatabaseInfo.cs‎

Copy file name to clipboardExpand all lines: src/Npgsql/NpgsqlDatabaseInfo.cs
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ internal static ConcurrentDictionary<string, NpgsqlDatabaseInfo> Cache
7979
/// </summary>
8080
public virtual bool SupportsRangeTypes => Version >= new Version(9, 2, 0);
8181
/// <summary>
82+
/// Whether the backend supports enum types.
83+
/// </summary>
84+
public virtual bool SupportsEnumTypes => Version >= new Version(8, 3, 0);
85+
/// <summary>
8286
/// Whether the backend supports the CLOSE ALL statement.
8387
/// </summary>
8488
public virtual bool SupportsCloseAll => Version >= new Version(8, 3, 0);
Collapse file

‎src/Npgsql/PostgresDatabaseInfo.cs‎

Copy file name to clipboardExpand all lines: src/Npgsql/PostgresDatabaseInfo.cs
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ internal async Task LoadPostgresInfo(NpgsqlConnection conn, NpgsqlTimeout timeou
8282
// Order by primitives first, container later.
8383
// For arrays and ranges, join in the element OID and type (to filter out arrays of unhandled
8484
// types).
85-
static string GenerateTypesQuery(bool withRange, bool loadTableComposites)
85+
static string GenerateTypesQuery(bool withRange, bool withEnum, bool loadTableComposites)
8686
=> $@"
8787
/*** Load all supported types ***/
8888
SELECT ns.nspname, a.typname, a.oid, a.typrelid, a.typbasetype,
@@ -126,12 +126,12 @@ JOIN pg_attribute AS att ON (att.attrelid = typ.typrelid)
126126
attnum > 0 AND /* Don't load system attributes */
127127
NOT attisdropped
128128
ORDER BY typ.typname, att.attnum;
129-
129+
{(withEnum ? @"
130130
/*** Load enum fields ***/
131131
SELECT pg_type.oid, enumlabel
132132
FROM pg_enum
133133
JOIN pg_type ON pg_type.oid=enumtypid
134-
ORDER BY oid, enumsortorder;
134+
ORDER BY oid, enumsortorder;" : "")}
135135
";
136136

137137
internal async Task<List<PostgresType>> LoadBackendTypes(NpgsqlConnection conn, NpgsqlTimeout timeout, bool async)
@@ -144,7 +144,7 @@ internal async Task<List<PostgresType>> LoadBackendTypes(NpgsqlConnection conn,
144144
throw new TimeoutException();
145145
}
146146

147-
var typeLoadingQuery = GenerateTypesQuery(SupportsRangeTypes, conn.Settings.LoadTableComposites);
147+
var typeLoadingQuery = GenerateTypesQuery(SupportsRangeTypes, SupportsEnumTypes, conn.Settings.LoadTableComposites);
148148

149149
using (var command = new NpgsqlCommand(typeLoadingQuery, conn))
150150
{

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.