lelit/pglast

parse exit on multi thread when sql syntax error (12-latest)

Closed this issue · 4 comments

hi.
we have issue use pglast at multithread environment. when parsing a sql with wrong syntax, it exit with error code 2.
Would you please help to take a look ?

Thanks
hong

the simple code to reproduce:

from pglast import parse_sql
import time
import threading

cmd = 'SELECT * FROM (SELECT DISTINCT ON (Item) "Item", "Location" FROM "UN"."t10" ORDER BY "Item", "Location" DESC) ORDER BY "Location" DESC;'
def parser():
	try:
		try:
			parse_sql(cmd)
		except Exception as e:
			print(e)
			raise
	except:
		time.sleep(1)
		pass

for i in range(2):
	x = threading.Thread(target=parser)
	time.sleep(1)
	x.start()

while 1:
	pass
lelit commented

Thank you, I'll investigate as time permit, but I'm pretty busy on other things at the moment.
I see you already opened a twin issue pganalyze/libpg_query#97.

@lelit thanks, i am investing too.

lelit commented

Can I assume this is fixed in v3?