@@ -5893,6 +5893,74 @@ static bool isyesno(const TEXT* buffer)
5893
5893
}
5894
5894
5895
5895
5896
+ static bool printUser11()
5897
+ {
5898
+ if (!frontendTransaction())
5899
+ return false;
5900
+
5901
+ const char* sql = "SELECT MON$ATTACHMENT_NAME, MON$USER, MON$ROLE "
5902
+ "FROM MON$ATTACHMENTS WHERE MON$ATTACHMENT_ID = CURRENT_CONNECTION";
5903
+
5904
+ Firebird::RefPtr<Firebird::IStatement> st(Firebird::REF_NO_INCR,
5905
+ DB->prepare(fbStatus, fbTrans, 0, sql, 3, Firebird::IStatement::PREPARE_PREFETCH_METADATA));
5906
+ if (failed())
5907
+ return false;
5908
+ Firebird::RefPtr<Firebird::IMessageMetadata> m(Firebird::REF_NO_INCR,
5909
+ st->getOutputMetadata(fbStatus));
5910
+ if (failed())
5911
+ return false;
5912
+ unsigned bs = m->getMessageLength(fbStatus);
5913
+ if (failed())
5914
+ return false;
5915
+ Firebird::UCharBuffer outBuf;
5916
+ UCHAR* buf = outBuf.getBuffer(bs);
5917
+ st->execute(fbStatus, fbTrans, NULL, NULL, m, buf);
5918
+ if (failed())
5919
+ return false;
5920
+
5921
+ struct FieldInfo
5922
+ {
5923
+ const char* text;
5924
+ const char* skip;
5925
+ };
5926
+ FieldInfo fieldInfo[3] = {
5927
+ {"Database", NULL},
5928
+ {"User", NULL},
5929
+ {"Role", "NONE"}
5930
+ };
5931
+
5932
+ bool wasOut = false;
5933
+ for (unsigned i = 0; i < FB_NELEM(fieldInfo); ++i)
5934
+ {
5935
+ IsqlVar v;
5936
+ if (ISQL_fill_var(&v, m, i, buf) == ps_ERR)
5937
+ return false;
5938
+ if (*v.nullInd)
5939
+ continue;
5940
+
5941
+ Firebird::string txt;
5942
+ switch(v.type & ~1)
5943
+ {
5944
+ case SQL_TEXT:
5945
+ txt.assign(v.value.asChar, v.length);
5946
+ break;
5947
+ case SQL_VARYING:
5948
+ txt.assign(v.value.asVary->vary_string, v.value.asVary->vary_length);
5949
+ break;
5950
+ }
5951
+ txt.trim();
5952
+ if (fieldInfo[i].skip && txt == fieldInfo[i].skip)
5953
+ continue;
5954
+
5955
+ isqlGlob.printf("%s%s: %s", wasOut ? ", " : "", fieldInfo[i].text, txt.c_str());
5956
+ wasOut = true;
5957
+ }
5958
+ if (wasOut)
5959
+ isqlGlob.printf("%s", NEWLINE);
5960
+ return true;
5961
+ }
5962
+
5963
+
5896
5964
static processing_state newdb(TEXT* dbname,
5897
5965
const TEXT* usr,
5898
5966
const TEXT* psw,
@@ -6053,10 +6121,27 @@ static processing_state newdb(TEXT* dbname,
6053
6121
}
6054
6122
}
6055
6123
6124
+ // CVC: We do not require those pesky transactions for -x or -a options.
6125
+ // Metadata extraction works exclusively with default transaction gds__trans.
6126
+
6127
+ if (start_user_trans)
6128
+ {
6129
+ // Start the user transaction and default transaction
6130
+
6131
+ if (!M__trans)
6132
+ {
6133
+ M_Transaction();
6134
+ if (D__trans)
6135
+ commit_trans(&D__trans);
6136
+ if (setValues.Autocommit)
6137
+ D_Transaction();
6138
+ }
6139
+ }
6140
+
6056
6141
// CVC: Do not put the user and pw used to extract metadata in a script!
6057
6142
// Only acknowledge user connection parameters in interactive logins.
6058
6143
6059
- if (Interactive)
6144
+ if (Interactive && !printUser11() )
6060
6145
{
6061
6146
if (local_usr[0] != '\0')
6062
6147
{
@@ -6080,23 +6165,6 @@ static processing_state newdb(TEXT* dbname,
6080
6165
}
6081
6166
}
6082
6167
6083
- // CVC: We do not require those pesky transactions for -x or -a options.
6084
- // Metadata extraction works exclusively with default transaction gds__trans.
6085
-
6086
- if (start_user_trans)
6087
- {
6088
- // Start the user transaction and default transaction
6089
-
6090
- if (!M__trans)
6091
- {
6092
- M_Transaction();
6093
- if (D__trans)
6094
- commit_trans(&D__trans);
6095
- if (setValues.Autocommit)
6096
- D_Transaction();
6097
- }
6098
- }
6099
-
6100
6168
global_Stmt = NULL;
6101
6169
6102
6170
return SKIP;
0 commit comments