@@ -5287,45 +5287,41 @@ postgresImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid)
5287
5287
"SELECT relname, "
5288
5288
" attname, "
5289
5289
" format_type(atttypid, atttypmod), "
5290
- " attnotnull, " );
5290
+ " attnotnull, "
5291
+ " pg_get_expr(adbin, adrelid), " );
5291
5292
5292
5293
/* Generated columns are supported since Postgres 12 */
5293
5294
if (PQserverVersion (conn ) >= 120000 )
5294
5295
appendStringInfoString (& buf ,
5295
- " attgenerated, "
5296
- " pg_get_expr(adbin, adrelid), " );
5296
+ " attgenerated, " );
5297
5297
else
5298
5298
appendStringInfoString (& buf ,
5299
- " NULL, "
5300
- " pg_get_expr(adbin, adrelid), " );
5299
+ " NULL, " );
5301
5300
5302
5301
if (import_collate )
5303
5302
appendStringInfoString (& buf ,
5304
5303
" collname, "
5305
- " collnsp.nspname "
5306
- "FROM pg_class c "
5307
- " JOIN pg_namespace n ON "
5308
- " relnamespace = n.oid "
5309
- " LEFT JOIN pg_attribute a ON "
5310
- " attrelid = c.oid AND attnum > 0 "
5311
- " AND NOT attisdropped "
5312
- " LEFT JOIN pg_attrdef ad ON "
5313
- " adrelid = c.oid AND adnum = attnum "
5304
+ " collnsp.nspname " );
5305
+ else
5306
+ appendStringInfoString (& buf ,
5307
+ " NULL, NULL " );
5308
+
5309
+ appendStringInfoString (& buf ,
5310
+ "FROM pg_class c "
5311
+ " JOIN pg_namespace n ON "
5312
+ " relnamespace = n.oid "
5313
+ " LEFT JOIN pg_attribute a ON "
5314
+ " attrelid = c.oid AND attnum > 0 "
5315
+ " AND NOT attisdropped "
5316
+ " LEFT JOIN pg_attrdef ad ON "
5317
+ " adrelid = c.oid AND adnum = attnum " );
5318
+
5319
+ if (import_collate )
5320
+ appendStringInfoString (& buf ,
5314
5321
" LEFT JOIN pg_collation coll ON "
5315
5322
" coll.oid = attcollation "
5316
5323
" LEFT JOIN pg_namespace collnsp ON "
5317
5324
" collnsp.oid = collnamespace " );
5318
- else
5319
- appendStringInfoString (& buf ,
5320
- " NULL, NULL "
5321
- "FROM pg_class c "
5322
- " JOIN pg_namespace n ON "
5323
- " relnamespace = n.oid "
5324
- " LEFT JOIN pg_attribute a ON "
5325
- " attrelid = c.oid AND attnum > 0 "
5326
- " AND NOT attisdropped "
5327
- " LEFT JOIN pg_attrdef ad ON "
5328
- " adrelid = c.oid AND adnum = attnum " );
5329
5325
5330
5326
appendStringInfoString (& buf ,
5331
5327
"WHERE c.relkind IN ("
@@ -5405,9 +5401,9 @@ postgresImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid)
5405
5401
attname = PQgetvalue (res , i , 1 );
5406
5402
typename = PQgetvalue (res , i , 2 );
5407
5403
attnotnull = PQgetvalue (res , i , 3 );
5408
- attgenerated = PQgetisnull (res , i , 4 ) ? (char * ) NULL :
5404
+ attdefault = PQgetisnull (res , i , 4 ) ? (char * ) NULL :
5409
5405
PQgetvalue (res , i , 4 );
5410
- attdefault = PQgetisnull (res , i , 5 ) ? (char * ) NULL :
5406
+ attgenerated = PQgetisnull (res , i , 5 ) ? (char * ) NULL :
5411
5407
PQgetvalue (res , i , 5 );
5412
5408
collname = PQgetisnull (res , i , 6 ) ? (char * ) NULL :
5413
5409
PQgetvalue (res , i , 6 );
0 commit comments