Skip to content

Commit

Permalink
Fix older postgres versions (#7892)
Browse files Browse the repository at this point in the history
This still *leaves out* fields that were removed in postgres 17,
though.

They seem pretty marginal, but it's worth discussing what we really
want to do there. I think this approach is good enough to ship an
alpha with, though.

---------

Co-authored-by: Aljaž Mur Eržen <[email protected]>
  • Loading branch information
msullivan and aljazerzen authored Oct 23, 2024
1 parent 0378866 commit b572793
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
12 changes: 6 additions & 6 deletions edb/pgsql/metaschema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6479,15 +6479,16 @@ def _generate_sql_information_schema(
SELECT attrelid,
attname,
atttypid,
attstattarget,
attlen,
attnum,
attnum as attnum_internal,
attndims,
attcacheoff,
atttypmod,
attbyval,
attalign,
attstorage,
attalign,
attnotnull,
atthasdef,
atthasmissing,
Expand All @@ -6497,7 +6498,6 @@ def _generate_sql_information_schema(
attislocal,
attinhcount,
attcollation,
attstattarget,
attacl,
attoptions,
attfdwoptions,
Expand All @@ -6522,6 +6522,7 @@ def _generate_sql_information_schema(
SELECT pc_oid as attrelid,
col_name as attname,
COALESCE(atttypid, 25) as atttypid, -- defaults to TEXT
COALESCE(attstattarget, -1) as attstattarget,
COALESCE(attlen, -1) as attlen,
(ROW_NUMBER() OVER (
PARTITION BY pc_oid
Expand All @@ -6532,8 +6533,8 @@ def _generate_sql_information_schema(
COALESCE(attcacheoff, -1) as attcacheoff,
COALESCE(atttypmod, -1) as atttypmod,
COALESCE(attbyval, FALSE) as attbyval,
COALESCE(attalign, 'i') as attalign,
COALESCE(attstorage, 'x') as attstorage,
COALESCE(attalign, 'i') as attalign,
required as attnotnull,
-- Always report no default, to avoid expr trouble
false as atthasdef,
Expand All @@ -6544,7 +6545,6 @@ def _generate_sql_information_schema(
COALESCE(attislocal, TRUE) as attislocal,
COALESCE(attinhcount, 0) as attinhcount,
COALESCE(attcollation, 0) as attcollation,
COALESCE(attstattarget, -1) as attstattarget,
attacl,
attoptions,
attfdwoptions,
Expand Down Expand Up @@ -6645,14 +6645,15 @@ def _generate_sql_information_schema(
attrelid,
attname,
atttypid,
attstattarget,
attlen,
attnum,
attndims,
attcacheoff,
atttypmod,
attbyval,
attalign,
attstorage,
attalign,
attnotnull,
atthasdef,
atthasmissing,
Expand All @@ -6662,7 +6663,6 @@ def _generate_sql_information_schema(
attislocal,
attinhcount,
attcollation,
attstattarget,
attacl,
attoptions,
attfdwoptions,
Expand Down
13 changes: 12 additions & 1 deletion edb/server/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,9 @@ async def create_branch(
elif line.startswith('CREATE TYPE'):
if any(skip in line for skip in to_skip):
skipping = True
elif line == 'SET transaction_timeout = 0;':
continue

if skipping:
continue
new_lines.append(line)
Expand Down Expand Up @@ -1535,6 +1538,15 @@ def cleanup_tpldbdump(tpldbdump: bytes) -> bytes:
flags=re.MULTILINE,
)

# PostgreSQL 17 adds a transaction_timeout config setting that
# didn't exist on earlier versions.
tpldbdump = re.sub(
rb'^SET transaction_timeout = 0;$',
rb'',
tpldbdump,
flags=re.MULTILINE,
)

return tpldbdump


Expand Down Expand Up @@ -2144,7 +2156,6 @@ async def _populate_misc_instance_data(
json.dumps(json_single_role_metadata),
)

assert backend_params.has_create_database
if not backend_params.has_create_database:
await _store_static_json_cache(
ctx,
Expand Down

0 comments on commit b572793

Please sign in to comment.