commit 9d57484444e28a6c89906bb55afbbdffeb23948a
parent 56f899e2f4c31157ee1dc59a8a6dc5c3c863f27e
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 28 Jan 2024 22:38:01 +0100
substring does not work, use regex
Diffstat:
5 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/backenddb/pg_insert_transfer.c b/src/backenddb/pg_insert_transfer.c
@@ -60,7 +60,8 @@ TMH_PG_insert_transfer (
"SELECT"
" $1, $2, $3, account_serial, $5"
" FROM merchant_accounts"
- " WHERE SUBSTRING(payto_uri,STRPOS(payto_uri,'?'))=SUBSTRING($4,STRPOS($4,'?'))"
+ " WHERE REGEXP_REPLACE(payto_uri,'\?.*','')"
+ " =REGEXP_REPLACE($4,'\?.*','')"
" AND merchant_serial="
" (SELECT merchant_serial"
" FROM merchant_instances"
diff --git a/src/backenddb/pg_lookup_account.c b/src/backenddb/pg_lookup_account.c
@@ -49,7 +49,8 @@ TMH_PG_lookup_account (void *cls,
"SELECT"
" account_serial"
" FROM merchant_accounts"
- " WHERE SUBSTRING(payto_uri,STRPOS(payto_uri,'?'))=SUBSTRING($2,STRPOS($2,'?'))"
+ " WHERE REGEXP_REPLACE(payto_uri,'\?.*','')"
+ " =REGEXP_REPLACE($2,'\?.*','')"
" AND merchant_serial="
" (SELECT merchant_serial"
" FROM merchant_instances"
diff --git a/src/backenddb/pg_lookup_transfers.c b/src/backenddb/pg_lookup_transfers.c
@@ -194,7 +194,8 @@ TMH_PG_lookup_transfers (void *cls,
" WHERE execution_time < $2"
" AND execution_time >= $3"
" AND credit_serial > $4"
- " AND SUBSTRING(payto_uri,STRPOS(payto_uri,'?'))=SUBSTRING($6,STRPOS($6,'?'))"
+ " AND REGEXP_REPLACE(payto_uri,'\?.*','')"
+ " =REGEXP_REPLACE($6,'\?.*','')"
" AND merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
@@ -218,7 +219,8 @@ TMH_PG_lookup_transfers (void *cls,
" WHERE execution_time < $2"
" AND execution_time >= $3"
" AND credit_serial < $4"
- " AND SUBSTRING(payto_uri,STRPOS(payto_uri,'?'))=SUBSTRING($6,STRPOS($6,'?'))"
+ " AND REGEXP_REPLACE(payto_uri,'\?.*','')"
+ " =REGEXP_REPLACE($6,'\?.*','')"
" AND merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
@@ -331,7 +333,8 @@ TMH_PG_lookup_transfers (void *cls,
" JOIN merchant_accounts USING (account_serial)"
" LEFT JOIN merchant_transfer_signatures USING (credit_serial)"
" WHERE credit_serial > $2"
- " AND SUBSTRING(payto_uri,STRPOS(payto_uri,'?'))=SUBSTRING($4,STRPOS($4,'?'))"
+ " AND REGEXP_REPLACE(payto_uri,'\?.*','')"
+ " =REGEXP_REPLACE($4,'\?.*','')"
" AND merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
@@ -356,7 +359,8 @@ TMH_PG_lookup_transfers (void *cls,
" JOIN merchant_accounts USING (account_serial)"
" LEFT JOIN merchant_transfer_signatures USING (credit_serial)"
" WHERE credit_serial < $2"
- " AND SUBSTRING(payto_uri,STRPOS(payto_uri,'?'))=SUBSTRING($4,STRPOS($4,'?'))"
+ " AND REGEXP_REPLACE(payto_uri,'\?.*','')"
+ " =REGEXP_REPLACE($4,'\?.*','')"
" AND merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"
diff --git a/src/backenddb/pg_select_account_by_uri.c b/src/backenddb/pg_select_account_by_uri.c
@@ -73,7 +73,8 @@ TMH_PG_select_account_by_uri (void *cls,
" (SELECT merchant_serial "
" FROM merchant_instances"
" WHERE merchant_id=$1)"
- " AND SUBSTRING(payto_uri,STRPOS(payto_uri,'?'))=SUBSTRING($2,STRPOS($2,'?'))");
+ " AND REGEXP_REPLACE(payto_uri,'\?.*','')"
+ " =REGEXP_REPLACE($2,'\?.*','')");
return GNUNET_PQ_eval_prepared_singleton_select (pg->conn,
"select_account",
params,
diff --git a/src/backenddb/pg_update_wirewatch_progress.c b/src/backenddb/pg_update_wirewatch_progress.c
@@ -45,7 +45,8 @@ TMH_PG_update_wirewatch_progress (
"update_wirewatch_progress",
"UPDATE merchant_accounts"
" SET last_bank_serial=$3"
- " WHERE SUBSTRING(payto_uri,STRPOS(payto_uri,'?'))=SUBSTRING($2,STRPOS($2,'?'))"
+ " WHERE REGEXP_REPLACE(payto_uri,'\?.*','')"
+ " =REGEXP_REPLACE($2,'\?.*','')"
" AND merchant_serial ="
" (SELECT merchant_serial"
" FROM merchant_instances"