Skip to content
Open
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
2 changes: 1 addition & 1 deletion contrib/try_convert/scripts/check_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
preline = lines[i-1]
line = lines[i]
if len(line) > 0 and len(preline) > 0 and (line[0] == '-' or line[0] == '+') and (preline[0] != '-' and preline[0] != '+'):
words = re.split('::|\*|;|\n| |\(|\)|,|\.|\".*\"|\'.*\'|<.*>', preline)
words = re.split('::|\\*|;|\n| |\\(|\\)|,|\\.|\".*\"|\'.*\'|<.*>', preline)
ans = []
is_prining = False
for word in words:
Expand Down
12 changes: 6 additions & 6 deletions contrib/try_convert/scripts/error_safe_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

import os, glob

p_any = '(?:\S| |\t|\n+\t|\n+ |\n+#|\n+/|\n+\$)+?'
p_spaces = '\s*'
p_any = '(?:\\S| |\t|\n+\t|\n+ |\n+#|\n+/|\n+\\$)+?'
p_spaces = '\\s*'

def create_pattern(funcCall):
return '\n(\w+)\s+?(\w+)' + p_spaces + '\((' + p_any + ')\)' + p_spaces + '(\n\{' + '(' + p_any + ')' + f'({funcCall})' + '\s*' + '(' + p_any + ')' + '\n+\})'
return '\n(\\w+)\\s+?(\\w+)' + p_spaces + '\\((' + p_any + ')\\)' + p_spaces + '(\n\\{' + '(' + p_any + ')' + f'({funcCall})' + '\\s*' + '(' + p_any + ')' + '\n+\\})'

pattern = create_pattern('ereturn')

Expand Down Expand Up @@ -100,9 +100,9 @@ def find_functions_with_call(functions):

if m[5] != 'ereturn':
func_call = m[4][-20:] + m[5] + m[6][:20]
safe_call_pattern = f'if{p_spaces}\(!{m[5]}\({p_any}\)\)'
safe_call_void_pattern = f'\(void\){p_spaces}{m[5]}\({p_any}\)\)'
direct_safe_call_pattern = f'DirectFunctionCall1Safe\({m[5]}'
safe_call_pattern = f'if{p_spaces}\\(!{m[5]}\\({p_any}\\)\\)'
safe_call_void_pattern = f'\\(void\\){p_spaces}{m[5]}\\({p_any}\\)\\)'
direct_safe_call_pattern = f'DirectFunctionCall1Safe\\({m[5]}'
if re.search(safe_call_pattern, func_call) is None and \
re.search(safe_call_void_pattern, func_call) is None and \
re.search(direct_safe_call_pattern, func_call) is None:
Expand Down
14 changes: 7 additions & 7 deletions contrib/try_convert/scripts/find_calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@

from general import source_filenames

p_any = '(?:\S| |\t|\n+\t|\n+ |\n+#|\n+/|\n+\$)+?'
p_spaces = '\s*'
p_space = '\s+'
p_any = '(?:\\S| |\t|\n+\t|\n+ |\n+#|\n+/|\n+\\$)+?'
p_spaces = '\\s*'
p_space = '\\s+'


def remove_comments(body):
body = re.sub('".*?"', '""', body)
body = re.sub('/\*[\s\S]*?\*/', '/* */', body)
body = re.sub('/\\*[\\s\\S]*?\\*/', '/* */', body)
return body

def find_functions(func_names, text):

func_names_pattern_list = '|'.join(func_names)
func_names_pattern = f'((?:{func_names_pattern_list}))'

func_pattern = '\n(\w+)\s+?' + func_names_pattern + p_spaces + '\((' + p_any + ')\)' + p_spaces + '(\n\{' + '(' + p_any + ')' + '\n+\})'
func_pattern = '\n(\\w+)\\s+?' + func_names_pattern + p_spaces + '\\((' + p_any + ')\\)' + p_spaces + '(\n\\{' + '(' + p_any + ')' + '\n+\\})'

funcs = []

Expand All @@ -50,7 +50,7 @@ def find_functions(func_names, text):

def find_safe_functions(text):

func_pattern = '\n((?:\w+\s+)+)(\w+)' + p_spaces + '\((' + p_any + 'Node' + p_spaces + '\*' + p_spaces + 'escontext' + ')\)' + p_spaces + '(\n\{' + '(' + p_any + ')' + '\n+\})'
func_pattern = '\n((?:\\w+\\s+)+)(\\w+)' + p_spaces + '\\((' + p_any + 'Node' + p_spaces + '\\*' + p_spaces + 'escontext' + ')\\)' + p_spaces + '(\n\\{' + '(' + p_any + ')' + '\n+\\})'

funcs = []

Expand All @@ -62,7 +62,7 @@ def find_safe_functions(text):
return funcs

def create_pattern(funcCall):
return '\n((?:\w+\s+)+)(\w+)' + p_spaces + '\((' + p_any + ')\)' + p_spaces + '(\n\{' + '(' + p_any + ')' + '\W' + f'({funcCall})' + '\W' + '(' + p_any + ')' + '\n+\})'
return '\n((?:\\w+\\s+)+)(\\w+)' + p_spaces + '\\((' + p_any + ')\\)' + p_spaces + '(\n\\{' + '(' + p_any + ')' + '\\W' + f'({funcCall})' + '\\W' + '(' + p_any + ')' + '\n+\\})'


def find_functions_with_call(functions):
Expand Down
12 changes: 6 additions & 6 deletions contrib/try_convert/scripts/find_casts.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def get_extensions():
return create_casts, dict(create_functions)

def find_create_casts_in_text(text):
create_cast_pattern = 'CREATE CAST\s*\((\w+) AS (\w+)\)\s*([\w\s\(\)]+);'
create_cast_pattern = 'CREATE CAST\\s*\\((\\w+) AS (\\w+)\\)\\s*([\\w\\s\\(\\)]+);'
create_casts = []

for target, source, f in re.findall(create_cast_pattern, text):
Expand All @@ -159,29 +159,29 @@ def find_create_casts_in_text(text):
if re.match('WITHOUT FUNCTION', f) is not None:
create_casts += [(target, source, 'WITHOUT FUNCTION')]

m = re.match('WITH FUNCTION ([\w\(\)]+)', f)
m = re.match('WITH FUNCTION ([\\w\\(\\)]+)', f)
if m is not None:
# print(m[1])
create_casts += [(target, source, m[1])]

return create_casts

p_space = '\s+'
p_space = '\\s+'

def find_create_function_in_text(text):
create_function_pattern = 'CREATE FUNCTION' + p_space + '(\w+)\([\w\s,]+\)' + p_space + 'RETURNS' + p_space + '\w+' + p_space + 'AS' + p_space + '([\',\w\s]+)' + p_space + 'LANGUAGE[\w\s,]+;'
create_function_pattern = 'CREATE FUNCTION' + p_space + '(\\w+)\\([\\w\\s,]+\\)' + p_space + 'RETURNS' + p_space + '\\w+' + p_space + 'AS' + p_space + '([\',\\w\\s]+)' + p_space + 'LANGUAGE[\\w\\s,]+;'
create_functions = {}

for sql_name, c_obj in re.findall(create_function_pattern, text):
# print(target, source, f)

m = re.fullmatch("\'(\w+)\'", c_obj)
m = re.fullmatch("\'(\\w+)\'", c_obj)
if m is not None:
c_name = m[1]
create_functions[sql_name] = c_name
continue

m = re.fullmatch("\'MODULE_PATHNAME\',\s+\'(\w+)\'", c_obj)
m = re.fullmatch("\'MODULE_PATHNAME\',\\s+\'(\\w+)\'", c_obj)
if m is not None:
c_name = m[1]
create_functions[sql_name] = c_name
Expand Down
12 changes: 6 additions & 6 deletions contrib/try_convert/scripts/find_ereturns.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@

from general import source_filenames

p_any = '(?:\S| |\t|\n+\t|\n+ |\n+#|\n+/|\n+\$)+?'
p_anys = '(?:\S| |\t|\n+\t|\n+ |\n+#|\n+/|\n+\$)*?'
p_spaces = '\s*'
p_space = '\s+'
p_any = '(?:\\S| |\t|\n+\t|\n+ |\n+#|\n+/|\n+\\$)+?'
p_anys = '(?:\\S| |\t|\n+\t|\n+ |\n+#|\n+/|\n+\\$)*?'
p_spaces = '\\s*'
p_space = '\\s+'

ereturn_pattern = 'ereturn\(' + p_any + '\);'
ereturn_pattern = 'ereturn\\(' + p_any + '\\);'

ereturns = {}

Expand All @@ -46,7 +46,7 @@
for m in matches:

def get_field(field, m):
errfield = re.search(f'{field}\("('+ p_anys + '"' + p_anys + ')[\)\n]', m)
errfield = re.search(f'{field}\\("('+ p_anys + '"' + p_anys + ')[\\)\n]', m)
if errfield is not None:
errfield = errfield[1]

Expand Down
12 changes: 6 additions & 6 deletions contrib/try_convert/scripts/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def filter_supported_casts(casts):
if cast[2] != 'WITH INOUT' and cast[2] != 'WITHOUT FUNCTION':
sql_func_name = cast[2]

m = re.match('(\w+)\(', sql_func_name)
m = re.match('(\\w+)\\(', sql_func_name)
if m is not None:
sql_func_name = m[1]

Expand Down Expand Up @@ -211,11 +211,11 @@ def filter_supported_casts(casts):
if re.search(r'bool', return_type) is None:
print(f' WARNING: safe function {name} returns result not bool')

m = re.match('(\w+)Safe', name)
m = re.match('(\\w+)Safe', name)
if m is not None:
loaded_null_functions[m[1]] = 1

m = re.match('(\w+)_safe', name)
m = re.match('(\\w+)_safe', name)
if m is not None:
loaded_null_functions[m[1]] = 1

Expand All @@ -233,14 +233,14 @@ def filter_supported_casts(casts):

from find_calls import get_all_functions_with

ereport_functions = get_all_functions_with('ereport\(ERROR,')
ereport_functions = get_all_functions_with('ereport\\(ERROR,')

unsafe_convert_functions = {}

for func_name in loaded_functions:
body = loaded_functions[func_name]

pattern_call = '(\w+)\s*\(([\s\S]*?)\)'
pattern_call = '(\\w+)\\s*\\(([\\s\\S]*?)\\)'

for token_match in re.finditer(pattern_call, body):

Expand Down Expand Up @@ -276,7 +276,7 @@ def filter_supported_casts(casts):
for func_name in loaded_functions:
body = loaded_functions[func_name]

pattern_call = '\w+'
pattern_call = '\\w+'

for token_match in re.finditer(pattern_call, body):

Expand Down
4 changes: 2 additions & 2 deletions gpMgmt/bin/gpcheckperf
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def parseMultiDDResult(out):
if o.find('multidd total bytes ') >= 0:
h = line[1:i]
o = o.split()
m = re.search("(^\d+)", o[-1])
m = re.search("(^\\d+)", o[-1])
if m is None:
sys.exit('[Error] expected %s to be a number' % o[-1])
bytes = int(m.group(1))
Expand All @@ -444,7 +444,7 @@ def parseMultiDDResult(out):
h = line[1:i]
o = o.split()
o[1] = o[1].replace(',', '.')
m = re.search("(^\d+.\d+)", o[1])
m = re.search("(^\\d+.\\d+)", o[1])
if m is None:
sys.exit('[Error] expected %s to be a floating point number' % o[1])
time = float(m.group(1))
Expand Down
2 changes: 1 addition & 1 deletion gpMgmt/bin/gpmemreport
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ProcessListing(object):
@classmethod
def process(cls, ps_dictionary):
cmd = ps_dictionary['COMMAND']
if re.match('^\S*postgres\S*\s', cmd) is not None:
if re.match('^\\S*postgres\\S*\\s', cmd) is not None:
if cmd.startswith('postgres:'):
if re.search(r'con\d+', cmd):
return GPDBQueryProcess(ps_dictionary)
Expand Down
2 changes: 1 addition & 1 deletion gpMgmt/bin/gpssh-exkeys
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ try:
# MPP-13617
def canonicalize(s):
if ':' not in s: return s
return '\[' + s + '\]'
return '\\[' + s + '\\]'


for h in GV.newHosts:
Expand Down
2 changes: 1 addition & 1 deletion src/backend/gporca/scripts/cal_bitmap_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def select_version(conn):
rows = curs.fetchall()
for row in rows:
log_output(row[0])
glob_gpdb_major_version = int(re.sub(".*Apache Cloudberry ([0-9]*)\..*", "\\1", row[0]))
glob_gpdb_major_version = int(re.sub(".*Apache Cloudberry ([0-9]*)\\..*", "\\1", row[0]))
log_output("GPDB major version is %d" % glob_gpdb_major_version)

log_output("Backend pid:")
Expand Down
4 changes: 2 additions & 2 deletions src/backend/gporca/scripts/fix_mdps.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def processLogFile(logFileLines):
print("Log file contains partial plans for %s, please update this file by hand" % (current_file))
read_plan = 0
elif actualSizeMatch:
actualSize = re.search('Actual size: (\d+)', line).group(1)
actualSize = re.search('Actual size: (\\d+)', line).group(1)
elif expectedSizeMatch:
expectedSize = re.search('Expected size: (\d+)', line).group(1)
expectedSize = re.search('Expected size: (\\d+)', line).group(1)
if not dryrun:
replacePlanSize(current_file, actualSize, expectedSize)
print("Changed plan size in %s \n" % (current_file))
Expand Down
2 changes: 1 addition & 1 deletion src/test/unit/mock/mocker.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def make_body(self):
if body:
return body

subscript = re.compile('\[\d*\]$')
subscript = re.compile('\\[\\d*\\]$')
# otherwise, general method
buf = []
# emit check_expected()
Expand Down
Loading